判断是否枚举中的匹配项

1.首先定义一个枚举:enum Colors { None = 0, Red = 1, Green = 2, Blue = 4 };2.判断所给的值在枚举中是否存在string[] colorStrings = { "0", "2", "8", "blue", "Blue", "Yellow", "Red, Green" }; foreach (string colorString in colorStrings) { Colors colorValue;
posted @ 2013-01-05 19:03  _YMW  阅读(3789)  评论(0编辑  收藏  举报