December 2001
Beginner
976 pages
22h 4m
English
Properties can be used exactly as the fields are used. For example, if you use the class you defined previously, you could write code as shown:
Module Module1
Sub Main()
Dim h As Horse = New Horse("Bucefalus", "black", 2)
h.height = 1.9
Console.Out.WriteLine("The height is {0} ", h.height)
End Sub
End Module
You construct a new Horse object and then you set its height to 1.9, and you output the value of the height property to the console. The second line in Sub Main (h.height = 1.9) will call the property procedure and execute its Set block. The Value implicit variable will be set to 1.9. That means it would pass verification using the If statement and will set the m_height field value to be 1.9.
Next you read the value (execute ...
Read now
Unlock full access