7.5. Static Members
Up until this point, all the methods, fields, and properties that we've discussed have been associated with an instance of a class. Every object has its own copy of the member and can manipulate it independently of what other objects are doing. But there might be times when you'll want to make a member common to all instances of a class. In other words, instead of having each object have its own copy of a field, there might be a field whose value will be shared by all objects of a given class. A common field, for example, can be useful to keep track of how many objects of a given type have been instantiated in an application. The C# language satisfies this need through static members that are associated with classes as a ...
Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.