Understanding the static keyword

Posted by user985482 on Programmers See other posts from Programmers or by user985482
Published on 2012-09-03T10:12:29Z Indexed on 2012/09/03 15:51 UTC
Read the original article Hit count: 498

Filed under:
|
|

I have some experience in developing with Java, Javascript and PHP.

I am reading Microsoft Visual C# 2010 Step by Step which I feel it is a very good book on introducing you to the C# language.

I seem to be having problems in understanding the static keyword. From what I understand this far if a class is declared static all methods and variable have to be static. The main method always is a static method so in the class that the main method exists all variables and methods are declared static if you have to call them in the main method. Also I have noticed that in order to call a static method from another class you do not need to create an object of that you can use the class name.

What are the advantages of declaring static variables and methods?

When should I declare static variable and methods?

© Programmers or respective owner

Related posts about c#

Related posts about learning