Last active
July 20, 2018 18:16
-
-
Save lfgrando/8794680896c864101b58f2047a4cbc9e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static string ToDescription<T>(this T source) | |
{ | |
FieldInfo fi = source.GetType().GetField(source.ToString()); | |
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); | |
// | |
return attributes.Length > 0 ? attributes[0].Description : source.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment