Skip to content

Instantly share code, notes, and snippets.

@alanjuden
Created January 21, 2014 22:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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