AcManager.Tools.Helpers.EnumExtension.GetDescription C# (CSharp) Method

GetDescription() public static method

public static GetDescription ( [ value ) : string
value [
return string
        public static string GetDescription([NotNull] this Enum value) {
            if (value == null) throw new ArgumentNullException(nameof(value));
            var type = value.GetType();
            var name = Enum.GetName(type, value);
            if (name == null) return null;

            var field = type.GetField(name);
            if (field == null) return null;

            var attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
            return attr?.Description;
        }
    }
EnumExtension