custom type index

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
VB.NET:
Public Class test
    Public Property AA As String
    Public Property AB As String
    Public Property XX As string
End Class

Dim testData As New test with {.AA = "a", .AB ="b", .XX="c"}
For i As Integer = 0 to 2

Next

is it possible to display the values in testData in the For loop with just one line? Are the properties indexed inside a class?
 
Are the properties indexed inside a class?
No they aren't. You could use Reflection and call GetProperties to get an array of PropertyInfo objects and then loop through that to get the value of each property but doing that with an object for which you know all the properties to begin with is a bit dodgy. You'd generally only do that in code designed to work with arbitrary types.
 
Back
Top