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