c# - Declaring private variable inside Main -


class program {     static void main(string[] args)     {         private int panda=3;                 } } 

compiler spits 4 errors when this. declaring private variable in main forbidden? why?

variables declared inside block (i.e. code between 2 curly braces) visible inside block, there no sense in declaring them private, public or protected.

class { private static int x=0;//make sense   static void main(string[] args)     {        private static int x=0; //does not make sense     } } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -