If you declare a variable as private, then you cannot access it outside the current class, and if you declare it as protected, then only the derived class will be able to access this variable. In your example, the main value of private and Protected does not change, so it does not matter how you declare it static or simple ...
class Test { protected static int var1; private static int var2; } class MainProgram : Test { private static int test; static void Main(string[] args) { Test.var1 = 2; Test.var2 = 5;
In the above code, you can see if we want the static variable to be available only in the current class, then you need to make it as private.
Chetan s
source share