var typeNames = new List<string>();
var enumType = typeof(MouduleType);
foreach (var value in Enum.GetValues(enumType))
{
var fieldInfo = enumType.GetField(Enum.GetName(enumType, value));
var descriptionAttribute =
fieldInfo.GetCustomAttribute(typeof(DescriptionAttribute), false) as DescriptionAttribute;
if (descriptionAttribute != null) typeNames.Add(descriptionAttribute.Description);
}
C#遍历获取枚举的DescriptionAttribute内容
最新推荐文章于 2024-08-13 13:41:52 发布