linq判断一个枚举的Name是否存在
2015-03-06 18:15 jiangys 阅读(1330) 评论(0) 编辑 收藏 举报比如,枚举如下:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
[Serializable] public enum PayType : int { /// <summary> /// AAA /// </summary> [Description("AAA")] AAA= 1, /// <summary> /// BBB /// </summary> [Description("BBB")] BBB= 2 }
调用时:
typeof(PayType).GetFields().Where(p => p.Name == “AAA”).Count() == 0