aaron_work
New member
- Joined
- May 7, 2010
- Messages
- 1
- Programming Experience
- Beginner
Hopefully there is a quick answer to this but I can't seem to find the correct words to search for an answer. I'm using VS 2010 so I have auto-implemented properties.
I have a class and I want to access the properties by a string.
Public Class MyClass
Property Prop1 As String
Property Prop2 As String
End Class
OK, Of course I can set/get the properties by doing this...
Dim MyVar = New MyClass
MyVar.Prop1 = "Prop1 Value"
MyVar.Prop2 = "Prop2 Value"
But, I also want to be able to access the variables something like this way....
Dim MyVar = New MyClass
MyVar.Items("Prop1") = "Prop1 Value"
MyVar.Items("Prop2") = "Prop2 Vaule"
How can I setup MyClass to work both ways?
Thanks,
Aaron
I have a class and I want to access the properties by a string.
Public Class MyClass
Property Prop1 As String
Property Prop2 As String
End Class
OK, Of course I can set/get the properties by doing this...
Dim MyVar = New MyClass
MyVar.Prop1 = "Prop1 Value"
MyVar.Prop2 = "Prop2 Value"
But, I also want to be able to access the variables something like this way....
Dim MyVar = New MyClass
MyVar.Items("Prop1") = "Prop1 Value"
MyVar.Items("Prop2") = "Prop2 Vaule"
How can I setup MyClass to work both ways?
Thanks,
Aaron