I am trying to iterate through properties of properties. Below is my sample class
Public Class Doc
Public Property DocName As String
Public Property flds As Flds
Public Sub New()
flds = New Flds()
End Sub
End Class
Public Class Flds
Public Property id As ID
Public Property name As Name
Public Sub New()
id = New ID()
name = New Name()
End Sub
End Class
Public Class ID
Public Property type As Integer
Public Property value As String
Public Property page As Integer
End Class
Public Class Name
Public Property type As String
Public Property value As String
Public Property page As Integer
End Class
And below is the code in my main module, here I am iterating through properties in Flds object, and within this, I need to iterate through properties of each property. Great if anyone could advise please.
Dim doc As Doc = New Doc()
Dim t As Type = doc.flds.GetType
For Each p As System.Reflection.PropertyInfo In t.GetProperties()
If p.CanRead Then
Dim strName = p.Name.ToString()
Dim strValue As String = p.GetValue(doc.flds, Nothing).ToString()
End If
Next