Skip to content

Instantly share code, notes, and snippets.

@papeMK2
Last active February 5, 2016 03:51
Show Gist options
  • Save papeMK2/012f41ee098528937af5 to your computer and use it in GitHub Desktop.
Save papeMK2/012f41ee098528937af5 to your computer and use it in GitHub Desktop.
EnumExtensionForWinRT.cs
/// <summary>
/// Enumの拡張クラス
/// </summary>
public static class EnumExtention
{
/// <summary>
/// DisplayのNameを返す
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string GetDisplayName(this Enum value)
{
return value.GetType()
.GetTypeInfo()
.GetDeclaredField(value.ToString())
.CustomAttributes
.FirstOrDefault().
NamedArguments.
FirstOrDefault().
TypedValue.
Value.
ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment