Shared Properties

In an object-oriented approach, fields should be wrapped by properties that gain access to fields. This also happens with shared members. A shared property can be implemented either as an auto-implemented property or explicitly. For instance, continuing with the preceding example, a shared property could be implemented as follows:

Public Shared Property DocumentCounter As Integer

You can still write shared properties the old-fashioned way for further manipulations, like this:

Private Shared _documentCounter As IntegerPublic Shared Property DocumentCounter As Integer    Get        Return _documentCounter    End Get    Set(value As Integer)        _documentCounter = value ...

Get Visual Basic 2015 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.