如何通过自定义vb.net对象的每个属性循环? [英] How to iterate through each property of a custom vb.net object?
本文介绍了如何通过自定义vb.net对象的每个属性循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么就可以进入每个在我的自定义对象的属性?它不是一个集合对象,但有这样的事情对于非集合对象?
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?
For Each entry as String in myObject
' Do stuff here...
Next
有字符串,整数和布尔特性在我的对象。
There are string, integer and boolean properties in my object.
推荐答案
通过使用反射,你可以做到这一点。在C#中,它看起来像;
By using reflection you can do that. In C# it looks like that;
PropertyInfo[] propertyInfo = myobject.GetType().GetProperties();
增加了一个VB.Net翻译:
Added a VB.Net translation:
Dim info() As PropertyInfo = myobject.GetType().GetProperties()
这篇关于如何通过自定义vb.net对象的每个属性循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文