如何遍历自定义 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屋!
查看全文