Last active
February 5, 2016 03:51
-
-
Save papeMK2/012f41ee098528937af5 to your computer and use it in GitHub Desktop.
EnumExtensionForWinRT.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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