Wednesday, 19 July 2017

What is the difference between public, static and void variables & method in C#.

Public declared variables or methods are accessible anywhere in the application.

 Static declared variables or methods are globally accessible without creating an instance of the class.
Static member are by default not globally accessible it depends upon the type of access modified used.
The compiler stores the address of the method as the entry point and uses this information to begin execution before any objects are created. And Void is a type modifier that states that the method or variable does not return any value.


Static classes/methods/variables are accessible throughout the application without creating instance. Compiler will store the method address as an entry point.

Public methods or variables are accessible throughout the application.

Void is used for the methods to indicate it will not return any value.

Share this


0 Comments

Advertisement