using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
///
/// 枚举扩展
///
public static class EnumExtension
{
///
/// 获取枚举描述
///
/// 枚举类型
///
public static string GetEnumDisplayName(this Enum enumType)
{
try
{
Type type = enumType.GetType();
var field = type.GetField(Enum.GetName(type, enumType));
string displayName = field.GetCustomAttribute().Name;
return displayName;
}
catch
{
return string.Empty;
}
}
}