Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Iterating Fields in a class
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00735219
Message ID:
00735268
Views:
7
This message has been marked as the solution to the initial question of the thread.
>Here is an example of what I am doing:
>
>MyClass oMyClass = new MyClass()
>oMyClass.city = "New Milford";
>oMyClass.state = "disillusion" ;
>oMyClass.etc = "etcetera,etcetera";
>
>System.Reflection.FieldInfo[] oFieldInfo = oMyClass.GetType().GetFields() ;			
>for(int i = 0 ; i < oFieldInfo.Length ; i++)
>{
>MessageBox.Show(oFieldInfo[i].Name.ToString())   ;
>
>}
>
>Anyone know if I’m on the right track here?
>

Yeah, you're on the right track. This will return the value of the field:
MessageBox.Show(oFieldInfo[i].GetValue(oMyClass).ToString());
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform