Vb.net 如何遍历对象列表中的每个对象中的每个属性

Vb.net 如何遍历对象列表中的每个对象中的每个属性,vb.net,Vb.net,所以我有一个对象列表,我想得到每个对象中的每个属性,并将其保存为字符串 对象看起来像 Public Class parameters Public Property test As String Public Property test_type As String Public Property user_test_name As String Public Property meas As String Public Property spec_min

所以我有一个对象列表,我想得到每个对象中的每个属性,并将其保存为字符串

对象看起来像

Public Class parameters
    Public Property test As String
    Public Property test_type As String
    Public Property user_test_name As String
    Public Property meas As String
    Public Property spec_min As String
    Public Property spec_max As String
    Public Property spec_unit As String

    Public Overrides Function ToString() As String
        Return user_test_name
    End Function
End Class
这就是我目前所拥有的

For Each parameters In param
    Dim myType As Type = GetType(parameters)
    Dim properties As System.Reflection.PropertyInfo() = myType.GetProperties()

    For Each p As System.Reflection.PropertyInfo In properties
        MsgBox(p.Name)
    Next
Next

…那么你的问题到底在哪里?该代码应该或多或少可以工作。但它不能!它一次又一次地穿过第一个物体!不,它不会这样做–但是您的所有类型都是相同的,所以输出当然是相同的。哦,Nvm,我想要每个属性中的值。我想我把问题写错了