请教关于枚举的问题 1.enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 }; =1,=2等等有什么作用? 2.Parse 方法
可以将一个或多个枚举常数的名称或数字值的字符串表示转换成等效的枚举对象
Colors myOrange = (Colors)Enum.Parse(typeof(Colors), "Red, Yellow"); Console.WriteLine("The myOrange value has the combined entries of {0}",
myOrange);
就可以得到Red, Yellow。
但是public enum Weekday { Sun, Mon, Tue, Wed, Thu, Fri, Sat } Weekday wd3=(Weekday)Weekday.Parse(typeof(Weekday),"Sun, Mon"); Console.WriteLine(wd3);
不能得到Sun, Mon。这是为什么呢?