I saw this in the set accessor of a property:
Set(ByVal value As DataSet)
What exactly does the stuff in the () mean? VS complained about it not being
there when I took it out not knowing it needed to be there.
Well... Under the covers, get and set accessors are methods. The
argument to the Set part of the property, is the value you want to pass
in. Properties are syntactic sugar, really.
Basically this:
Class SomeClass
Private _data As DataSet
Public Property Data As DataSet
Get
Return Me._data
End Get
Set (ByVal value As DataSet)
Me._data = value
End Set
End Property
End Class
Dim c As SomeClass = New SomeClass()
c.Data = New DataSet()
Turns into is something like (warning, this is psuedo code for
illustration purposes only!):
Class SomeClass
Private _data As DataSet
Public Function GetData () As DataSet
Return Me._data
End Function
Public Sub SetData (ByVal value As DataSet)
Me._data = value
End Sub
End Class
Dim c As SomeClass = New SomeClass()
c.SetData (New DataSet())
Of course, the compiler immits IL, not basic code - but that is
essentially what the il is doing. It is creating a get/set pair of
methods and calling them