15 lines
409 B
C#
15 lines
409 B
C#
using System.Reflection;
|
|
|
|
namespace YY.Admin.Core.Extension
|
|
{
|
|
public static class EnumExtensions
|
|
{
|
|
public static string GetDescription(this Enum value)
|
|
{
|
|
var field = value.GetType().GetField(value.ToString());
|
|
var attribute = field?.GetCustomAttribute<DescriptionAttribute>();
|
|
return attribute?.Description ?? value.ToString();
|
|
}
|
|
}
|
|
}
|