/// <summary> /// Returns the description associated with the specified enum value, or the value's /// .ToString() result if no string constant attribute is applied. /// </summary> public static string ToDescription(this IComparable input) { var attribute = input.GetAttributes <DescriptionAttribute>().FirstOrDefault(); return((attribute != null) ? attribute.GetDescription() : input.ToString()); }
/// <summary> /// Returns the string constant associated with the specified enum value, or the value's /// .ToString() result if no string constant attribute is applied. /// </summary> public static string ToStringConstant(this IComparable input) { var attribute = input.GetAttributes <StringConstantAttribute>().FirstOrDefault(); return((attribute != null) ? attribute.GetStringConstant() : input.ToString()); }