Is there a way I could access a property of a object either by a string or by
a delegate? For example if I have a class called Person, and Person has two
properties (FirstName, and Lastname) and I have a routine in the calling code
called PrintItem, could I do something like:
Public Module
Public Sub Main()
Dim MyPerson as Person = New Person
PrintItem(MyPer son, "FIRSTNAME" )
PrintItem(MyPer son, "LASTNAME")
End Sub
Public Sub PrintItem(byref P as Person, Byval PropertyNameToP rint as String)
(SOME CODE HERE TO DO P. AND THE PROPERTYNAMETO PRINT)
Windows.Forms.M essageBox.Show( P. XXXXX)
End Sub
End Module
a delegate? For example if I have a class called Person, and Person has two
properties (FirstName, and Lastname) and I have a routine in the calling code
called PrintItem, could I do something like:
Public Module
Public Sub Main()
Dim MyPerson as Person = New Person
PrintItem(MyPer son, "FIRSTNAME" )
PrintItem(MyPer son, "LASTNAME")
End Sub
Public Sub PrintItem(byref P as Person, Byval PropertyNameToP rint as String)
(SOME CODE HERE TO DO P. AND THE PROPERTYNAMETO PRINT)
Windows.Forms.M essageBox.Show( P. XXXXX)
End Sub
End Module
Comment