How to iterate through each property of a custom vb.net object?

后端 未结 4 1816
囚心锁ツ
囚心锁ツ 2020-12-07 21:25

How can I go through each of the properties in my custom object? It is not a collection object, but is there something like this for non-collection objects?

         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 21:44

    By using reflection you can do that. In C# it looks like that;

    PropertyInfo[] propertyInfo = myobject.GetType().GetProperties();
    

    Added a VB.Net translation:

    Dim info() As PropertyInfo = myobject.GetType().GetProperties()
    

提交回复
热议问题