创建枚举:
enum 类型名:类型
{
***1,***2,***3......;
}
类型:byte、sbyte、short、ushort、int、uint、long、ulong。
- 转字符串:Tostring();
- 字符串转枚举:(枚举类型名)Enum . Parse(typeof(枚举类型名),字符串);
Game game = (Game)Enum.Parse(typeof(Game),string);
-------------------------------------------------------------------
简单使用:
Switch(game)
{
case Game . start:
Console . WriteLine(“开始”);
break;
case Game . stop:
Console . WriteLine(“结束”);
break;
}
- string s = Enum . GetName(typeof(game),下标); cw......
- string [] arr = Enum . GetName(typeof(game)); foreach......