I have a simple program, WITHOUT "public int a;", the program runs no problem,
but after add "public int a;", the programm has errors, what is the problem?
there is no special meaning for this int field "a", i just want to try something and find this problem
Best How To :
You need to declare fields and properties at the class level, not the method:
public int a;
Because the access modifier has meaning in this context. In your method you can only have local variables and they can only be accessed from the method that they declared. Curly-braces determine the scope of local variables.So specifying an access modifier for them is not allowed.