DescriptionThe Shared keyword indicates that a type member is a shared member instead of an instance member. Shared members are available without creating an instance of the type; instance members can only be used through an instance. Consider the following simple class: Friend Class ClassForSharing Public Shared sharedValue As Integer Public unsharedValue As Integer End Class The following code block shows how to access each member. Dim realInstance As New ClassForSharing ClassForSharing.sharedValue = 5 realInstance.unsharedValue = 10 Shared members are indirectly shared among all instances of the class, even though they exist apart from all instances. The Shared keyword can be used with the following statements:
By default, all of these members are instance members unless qualified with the Shared keyword. See AlsoFor the statements listed above, see the related entries elsewhere in this chapter for usage information. |