Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Reflection;
using System.ComponentModel;
namespace YourNamespace
{
public static class Missing
{
public static string GetDescription(this Enum value)
{
FieldInfo info = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attribs = (DescriptionAttribute[])info.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attribs.Length > 0)
{
return attribs[0].Description;
}
else
{
return value.ToString();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.