I don't know what you want to achieve, but i guess, that you want to check the value of custom class property by it's name.
Check this example:
Sub Main
Dim ports As String() = {"d1", "x4"}
Dim i As Integer = 0
Dim myType As Type = GetType(Whatever)
Dim myPropInfo As PropertyInfo = Nothing
Try
For i = 0 To 1
myPropInfo = myType.GetProperty(ports(i))
Console.WriteLine("The property '{0}' of 'Whatever' class exists! ", myPropInfo.Name)
Next
Catch ex As NullReferenceException
Console.WriteLine("The property '{0}' of 'Whatever' class does not exists!", ports(i))
End Try
End Sub
Public Class Whatever
Private bd1 As Boolean = False
Public Property d1 As Boolean
Get
Return bd1
End Get
Set (value As Boolean)
bd1 = value
End Set
End Property
End Class
Result:
The property 'd1' of 'Whatever' class exists!
The property 'x4' of 'Whatever' class does not exists!
To get property value, use this:
Console.WriteLine(myPropInfo.GetValue(w, Reflection.BindingFlags.GetProperty, Nothing, Nothing, Nothing))
where
w
is an instance of
Whatever
class.
Returns:
False
For further information, please see:
Type.GetProperty[
^]
PropertyInfo.GetValue Method (Object, Object())[
^]
[EDIT]
Note: answer has been updated accordingly to changes made by OP.
In your case i'd suggest to use
Dictionary class[
^] as follow:
Dim doav As List(Of Dictionary(Of String, Boolean)) = New List(Of Dictionary(Of String, Boolean))
Dim myDict As Dictionary(Of String, Boolean) = New Dictionary(Of String, Boolean)
myDict.Add("d1", False)
myDict.Add("d42", True)
myDict.Add("d123", False)
myDict.Add("d1027", False)
myDict.Add("d1089", True)
myDict.Add("d2109", False)
myDict.Add("d4130", False)
myDict.Add("lei", True)
doav.Add(myDict)
Dim i As Integer = 0
myDict = doav(i)
For Each k In myDict.Keys
Console.WriteLine("The value of '{0}' Key is: {1}", k, myDict(k))
Next
Returns:
The value of 'd1' Key is: False
The value of 'd42' Key is: True
The value of 'd123' Key is: False
The value of 'd1027' Key is: False
The value of 'd1089' Key is: True
The value of 'd2109' Key is: False
The value of 'd4130' Key is: False
The value of 'lei' Key is: True
[/EDIT]