May 2010
Intermediate to advanced
1752 pages
41h 17m
English
A C# class may define any number of static members using the static keyword. When you do so, the member in question must be invoked directly from the class level, rather than from an object reference. To illustrate the distinction, consider your good friend System.Console. As you have seen, you do not invoke the WriteLine() method from the object level:
// Error! WriteLine() is not an object level method!
Console c = new Console();
c.WriteLine("I can't be printed...");
but instead simply prefix the class name to the static WriteLine() member:
// Correct! WriteLine() is a static method.
Console.WriteLine("Thanks...");
Simply put, static members are items that are deemed (by the class designer) to be so commonplace ...