C#의 문자열을 열거 한 를 얻으십시오.
안전한 열거 모드를 입력하십시오
클래스 효과적인 값 만 사용되도록하십시오.
명확하고 간결한 :public enum AuthenticationMethod { FORMS = 1, WINDOWSAUTHENTICATION = 2, SINGLESIGNON = 3 }
<式 式> <<> 다른 유형 변환 <🎜 🎜>
.
public sealed class AuthenticationMethod { private readonly string name; private readonly int value; public static readonly AuthenticationMethod FORMS = new AuthenticationMethod(1, "FORMS"); public static readonly AuthenticationMethod WINDOWSAUTHENTICATION = new AuthenticationMethod(2, "WINDOWS"); public static readonly AuthenticationMethod SINGLESIGNON = new AuthenticationMethod(3, "SSN"); private AuthenticationMethod(int value, string name) { this.name = name; this.value = value; } public override string ToString() { return name; } }
위 내용은 C#에서 열거의 문자열 표현을 어떻게 더 우아하게 얻을 수 있습니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!