What does it mean when you add the static keyword to a method?
public static void doSomething(){
//Well, do something!
}
Can you add the
Core of the static keyword that you will have only one copy at RAM of this (method /variable /class ) that's shared for all calling
When you add a "static" keyword to a method, it means that underlying implementation gives the same result for any instance of the class. Needless to say, result varies with change in the value of parameters
The static keyword, when applied to a class, tells the compiler to create a single instance of that class. It is not then possible to 'new' one or more instance of the class. All methods in a static class must themselves be declared static.
It is possible, And often desirable, to have static methods of a non-static class. For example a factory method when creates an instance of another class is often declared static as this means that a particular instance of the class containing the factor method is not required.
For a good explanation of how, when and where see MSDN