You would use reflection to do this.
Something like:
using System.Reflection;
Type t = typeof(MyObject);
MemberInfo[] members = t.GetMembers();
foreach(MemberInfo mi in members){
//Do what you want here
}
GetMembers gets all the members of the given type. There
is also GetProperties, GetMethods, GetInterfaces, etc.
Also, you can pick out a member by name instead of
retrieving an array: t.GetMethod("CookSalsburySteak");
HTH,
Charlie
-----Original Message-----
How can you see an object's members at run-time
programmatically. I want towrite code that looks like :
MyObject myObject;
foreach ( object member in myObject)
{
DoSomeThingWith(member);
}
Thanks,
Hananiel
.