如何遍历Objects vb列表中每个Object中的每个属性

时间:2013-06-05 21:22:39

标签: 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 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

0 个答案:

没有答案