lundi 23 juillet 2018

how to find all usages of enum in a method with reflection

For a specific method I want to know which specific values of a particular enum is being used (by reflection). For example:

public class Example1
{
    public enum MyEnum
    {
        None,
        One,
        Two,
        Three
    }

    public int Method1()
    {
        MyEnum myEnum = MyEnum.One;
        Console.WriteLine("myEnum " + myEnum);
        return (int)myEnum;
    }
}

This method uses the value MyEnum.One of the enum MyEnum.





Aucun commentaire:

Enregistrer un commentaire