判断一个变量是不是在指定的集合 ENUM中
enum AA { EA=1, EB, EC, ED, EE };
1 //可以用反射:
2public bool InRect(AA a)
3{
4object[] oRet=typeof(AA).GetMember(a.ToString());
5if(oRet.Length==1)
6return true;
7return false;
8}
1 //那样就可以这样调用;
2AA test=AA.EA
3
4if(InRect(test))
5 MessageBox.Show("是在里面");