(1) 使用Enum.GetName()
(2) 使用ToString()方法
(2) 使用ToString()方法
public enum AuthMethod
{
FORMS = 1,
WINDOWSAUTHENTICATION = 2,
SINGLESIGNON = 3
}
static void StringEnums()
{
AuthMethod auth = AuthMethod.FORMS;
string str = Enum.GetName(typeof(AuthMethod), auth);
Console.WriteLine(str);
string str = AuthMethod.FORMS.ToString();
Console.WriteLine(str);
}