String representation of an Enum

后端 未结 30 2458
不思量自难忘°
不思量自难忘° 2020-11-22 02:44

I have the following enumeration:

public enum AuthenticationMethod
{
    FORMS = 1,
    WINDOWSAUTHENTICATION = 2,
    SINGLESIGNON = 3
}

T

30条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 03:06

    Just use the ToString() method

    public enum any{Tomato=0,Melon,Watermelon}
    

    To reference the string Tomato, just use

    any.Tomato.ToString();
    

提交回复
热议问题