枚举的操作

enum Language { Chinese = 0, English = 1 }

Language language = Language.Chinese;
将枚举转为字符串:
Convert.ToString(language);

将枚举转为整型:
Convert.ToInt32(language);

将字符串转为枚举:
Language language = (Language)Enum.Parse(typeof(Language), "Chinese");

将整型转为枚举:
Language language = (Language)Enum.Parse(typeof(Language), Convert.ToString(0));



你可能感兴趣的:(枚举)