110,567
社区成员
发帖
与我相关
我的任务
分享
var sexDescs = (from x in sexs
let type = x.GetType()
let name = Enum.GetName(type, x)
let fieldInfo = type.GetField(name)
let desc = Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute)) as DescriptionAttribute
select desc.Description
).ToList();
var sexDescs = sexs.Select(x => Attribute.GetCustomAttribute(x.GetType().GetField(Enum.GetName(x.GetType(), x)), typeof(DescriptionAttribute)))
.Cast<DescriptionAttribute>().Select(x => x.Description).ToList();