Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# class where T : enum C# 7.03

public static Dictionary<int, string> EnumNamedValues<T>() where T : System.Enum
{
    var result = new Dictionary<int, string>();
    var values = Enum.GetValues(typeof(T));

    foreach (int item in values)
        result.Add(item, Enum.GetName(typeof(T), item));
    return result;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #class #T #enum
ADD COMMENT
Topic
Name
8+6 =