End Get Set(ByVal Value As Integer) End Set

End Get Set(ByVal Value As Integer) End Set End Property Note the Value parameter that provides access to the incoming value. Thus, if we write: Dim cp As New CPerson( ) cp.Age = 20 then VB passes the value 20 into the Property procedure in the Value argument. 3.3.6 Instance and Shared Members The members of a class fall into two categories: Instance members Members that can only be accessed through an instance of the class, that is, through an object of the class. To put it another way, instance members “belong” to an individual object rather than to the class as a whole. Shared (static) members Members that can be accessed without creating an instance of the class. These members are shared among all instances of the class. More correctly, they are independent of any particular object of the class. To put it another way, shared members “belong” to the class as a whole, rather than to its individual objects or instances. Instance members are accessed by qualifying the member name with the object’s name. Here is an example: Dim APerson As New CPerson( ) APerson.Age = 50 To access a shared member, we simply qualify the member with the class name. For instance, the String class in the System namespace of the .NET Base Class Library has a shared method called Compare that compares two strings. Its syntax (in one form) is: Public Shared Function Compare(String, String) As Integer This function returns 0 if the strings are equal, -1 if the first string is less than the second, and 1 if the first string is greater than the second. Since the method is shared, we can write: Dim s As String = “steve” Dim t As String = “donna” MsgBox(String.Compare(s, t)) ‘ Displays 1 Note the way the Compare method is qualified with the name of the String class. Shared members are useful for keeping track of data that is independent of any particular instance of the class. For instance, suppose we want to keep track of the number of CPerson objects in existence at any given time. Then we write code such as the following: ‘ Declare a Private shared variable to hold the instance count
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat hosting services

Comments are closed.