VB.NET Iterating through objects of a structure

天涯浪子 提交于 2019-12-06 03:08:06

If this is just a one time thing you're probably going to have an easier time using a Dictionary instead, but you could do this with Reflection if you prefer to keep the structure.

This little code snippet will list out each structure member for you in a StringBuilder.

Dim sbOutput As New System.Text.StringBuilder
Dim t As Type = GetType(xyz)
For Each p As System.Reflection.FieldInfo In t.GetFields()
  sbOutput.AppendLine(p.Name)
Next
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!