enum 문자열 변환1 [C#] enum과 문자열 치환/변환 <속성(어트리뷰트)을 이용한 간단 치환 방법> public enum animal { [Description("똥꼬양이")] cat = 1, [Description(똥꾸 멍멍멍멍멍!!~)] dog = 2, [Description(똥 뙈 지)] pig = 3, } public static class EnumHelper { public static string GetDescription(Enum e) { Type type = e.GetType(); MemberInfo[] memInfo = type.GetMember(e.ToString()); if(memInfo != null && memInfo.Length > 0) { object[] attrs = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute),.. 2011. 2. 25. 이전 1 다음