Re: Another Refection question
Alan Baljeu <[email protected]> Thu, 15 Mar 2007 15:07:46 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <033e01c76735$37be1440$1dc80ac6@CTI> |
> I have never used reflection before. Can someone tell me how
> to use reflection to retrieve static objects and classes from a class?
Okay, that turned out to be too easy.
Type myType = typeof(MyClass);
System.Reflection.FieldInfo[] fields = myType.GetFields();
foreach (FieldInfo f in fields)
{
if (f.IsStatic)
{
}
}
System.Type[] classes = myType.GetNestedTypes();
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com