I'm kind of confuse on how to use ge开发者_运维技巧t and set in vb
how would i access the get/set method within the class and when i instantiate the class somewhere else?
in java i would make a 2 methods call like get_item set_item and i can just use the the method name i made. to retrieve or set within the class/object or when i instantiate it somewhere else. but in vb there is a property method and 2 methods inside(set,get)? i'm confuse... on how exactly to access these...
so for example if make a property call thing and made a property mstrThing
Property Thing() As String
Get
Return mstrThing
End Get
Set(ByVal value As String)
mstrThing = value
End Set
End Property
how would i access Thing's get and set methods?
Use property name within the instance method,
Thing="Hello"
To access properties outside the class, you have to specify public
access modifier.
Dim obj as New ClassName
obj.Thing="Hello"
When an assignment operator is used to assign a value, the set
accessor
will be invoked.
For more info visit this link.
精彩评论