mercredi 10 novembre 2021

Get object type from enum value

I have an enum defined wich stores multiple class names. Is there a way I can get the the type of an object given the enum value? The method GetObjectType when called with parameter Types.A should return the type of class A, how should it's body look like?

    public class A
    {

    }

    public class B
    {

    }

    public enum Types
    {
        A = 1,
        B = 2
    }

    public Type GetObjectType(Types type)
    {
         
    }




Aucun commentaire:

Enregistrer un commentaire