Static Versus Instance

Different types of members can be associated with instances of a type or with the type itself. This is where the static modifier comes in, allowing one to associate a member with a type rather than individual instances. Or to look at it another way, a type’s static members are shared across all instances, whereas instance members can be associated with and operate on individual instances. This sharing viewpoint is, in fact, how Visual Basic surfaces static members, using a Shared keyword rather than C#’s static.

As mentioned previously, classes allow bundling together state and operations in one notion, which closely aligns with object-oriented programming principles. When you are looking at the concept of shared static ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.