Mark S. kirjoitti:
Hello,
I have a static class with several hundred private static List<>. Does the
.NET framework keep an internal List/Hashtable/Collection of all my Lists
that I can loop over? If so, please show the syntax or docs reference, if
it's there I am unable to find it.
TIA,
M
I guess you can use Reflection
using System.Reflection;
...
MyClass myInstance = new MyClass();
// Get the type of MyClass.
Type myType = typeof(MyClass);
try {
FieldInfo[] myFields = myType.GetFields(BindingFlags.Static |
BindingFlags.NonPublic);
for(int i = 0; i < myFields.Length; i++) {
// Check that myFields[i].Name suites
Object obj = myFields[i].GetValue(myInstance);
}
} catch (Exception ex) {
Console.WriteLine("Exception {0}", ex);
}
--
Arto Viitanen