Created
April 3, 2018 09:16
-
-
Save joshi-kumar/9d0c98f6295c97007614b68e6fea7fa8 to your computer and use it in GitHub Desktop.
Dispaly ENUM class property name (Display attribute value)
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
public string GetDisplayName(Enum enumValue) | |
{ | |
return enumValue.GetType().GetMember(enumValue.ToString()) | |
.First() | |
.GetCustomAttribute<DisplayAttribute>() | |
.Name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment