Description Attribute Retrieval for Enum Type?

  • Thread starter Thread starter Schorschi
  • Start date Start date
S

Schorschi

I know I have seen this in C# somewhere, but can't seem to find the
right note, but need it in VB .Net!

Public Enum Numbers
<Description("This is 10.")> Ten = 10
<Description("This is 11.")> Eleven = 11
End Enum

How do I get the descrition text via code?

Dim theString As String = ???

Thx.
 
How do I get the descrition text via code?

Dim theString As String = ???

Dim ten As FieldInfo = GetType(Numbers).GetField("Ten")
Dim attr As DescriptionAttribute =
DirectCast(ten.GetCustomAttributes(GetType(DescriptionAttribute),
False)(0), DescriptionAttribute)
theString = attr.Description



Mattias
 
Back
Top