C# Get the enumeration name according to the key value of the enumeration

     public enum SubjectEnum
    {
        language=1,
        math=2,
        english=3,
        physics=4,
        chemistry=5,
        geography=6,
        biology=7,
        history=8,
        politics=9,
    }

public string GetEnumNameByKey(int key)

{

    return Enum.GetName(typeof( SubjectEnum ), key);
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326484207&siteId=291194637