Iv'e spent the last hour trying to get the value of a DisplayName attribute that's applied to a Class.
I find it simple enough to get the attribute values from methods and properties but I'm struggling with the class.
Could anyone help me out with this relatively small issue?
Sample below:
The Class
[DisplayName("Opportunity")]
public class Opportunity
{
// Code Omitted
}
The Variable
var classDisplayName = typeof(T).GetCustomAttributes(typeof(DisplayNameAttribute),true).FirstOrDefault().ToString();
I have spent much time on MSDN and SO but I guess I'm missing something stupidly simple.
Either way great question for future readers too
Any help greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire