Consider the following C# class declaration:
public class MyClass {
private enum Colours { Red, Green, Blue }
}
Which is sat in a separate class library/DLL.
Given just the typeof(MyClass) object (System.Type), is there any way to check if the class contains an enum called Colours at runtime and if so return it's corresponding System.Type object?
What I'm trying to do is write some generic code that's given the type of a class and determine if contains a specifically named enum inside and then query the values in the enum.
I know how to use Reflection to query things like GetFields, GetProperties etc. but there isn't a GetClasses or GetEnums method in System.Type.
I suspect this kind of information is in the assembly?
Aucun commentaire:
Enregistrer un commentaire