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 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.