C# ??????????
???????????? ???????[ 2013/9/27 15:46:38 ] ????????
????Enum????????????????????????? Char ????κ????????????????????????????????? Int32??????????????????????????????????????????????????????
??????????????????????? Char ????κ????????????????????????????
????Enum ???Щ????????????
????(1)?????????????????
????(2)??????????????????????????????
????(3)???????????????????????????????????
????(4)????????????????????????
??????????enum Colors { Red?? Green?? Blue?? Yellow };
????Enum-->String
????(1)????Object.ToString()????????Colors.Green.ToString()?????"Green"???????
????(2)????Enum????????GetName??GetNames??
????public static string GetName(Type enumType??Object value)
????public static string[] GetNames(Type enumType)
???????磺Enum.GetName(typeof(Colors)??3))??Enum.GetName(typeof(Colors)?? Colors.Blue))???????"Blue"
????Enum.GetNames(typeof(Colors))?????????????????顣
????String-->Enum
????(1)????Enum????????Parse??
????public static Object Parse(Type enumType??string value)
???????磺(Colors)Enum.Parse(typeof(Colors)?? "Red")
????Enum-->Int
????(1)??????????????? Char ??????????????????????????
???????磺(int)Colors.Red?? (byte)Colors.Green
????Int-->Enum
????(1)?????????????????????????????
???????磺Colors color = (Colors)2 ?????color???Colors.Blue
????(2)????Enum????????ToObject??
????public static Object ToObject(Type enumType??int value)
???????磺Colors color = (Colors)Enum.ToObject(typeof(Colors)?? 2)?????color???Colors.Blue
?????ж???????????????????е??????Enum.IsDefined
????public static bool IsDefined(Type enumType??Object value)
???????磺Enum.IsDefined(typeof(Colors)?? n))
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11