How to get enum value by string or int

后端 未结 10 1271
慢半拍i
慢半拍i 2020-12-07 12:43

How can I get the enum value if I have the enum string or enum int value. eg: If i have an enum as follows:

public enum TestEnum
{
    Value1 = 1,
    Value         


        
10条回答
  •  盖世英雄少女心
    2020-12-07 13:35

    Simply try this

    It's another way

    public enum CaseOriginCode
    {
        Web = 0,
        Email = 1,
        Telefoon = 2
    }
    
    public void setCaseOriginCode(string CaseOriginCode)
    {
        int caseOriginCode = (int)(CaseOriginCode)Enum.Parse(typeof(CaseOriginCode), CaseOriginCode);
    }
    

提交回复
热议问题