What is the use of static variable in C#? When to use it? Why can’t I declare the static variable inside method?

A static variable shares the value of it among all instances of the class. Example without declaring it static: public class Variable { public int i = 5; public void test() { i = i + 5; Console.WriteLine(i); } } public class Exercise { static void Main() { Variable var = new Variable(); var.test(); Variable … Read more

Superiority of unnamed namespace over static?

You’re basically referring to the section ยง7.3.1.1/2 from the C++03 Standard, The use of the static keyword is deprecated when declaring objects in a namespace scope; the unnamed-namespace provides a superior alternative. Note that this paragraph was already removed in C++11. static functions are per standard no longer deprecated! Nonetheless, unnamed namespace‘s are superior to … Read more