lundi 12 septembre 2016

Reflection: Get Class name from supplied property value

I have a base class with a number of child classes. Each class have a GetType property that will return a specified enum value. Is it possible to get the class name when I supply the enum value?

Example:

public enum EnumWorkflowJobType
{
    Class1 = 1,
    Class2 = 2,
} 

class MySubClass : ParentClass
{
    public override EnumType MyType()
    {
        return EnumType.Class1;
    }
 }

void main()
{ 
   var className = xxxx(EnumType.Class1); //I would like to get the value MySubClass back here.
}





Aucun commentaire:

Enregistrer un commentaire