Home All Groups Group Topic Archive Search About

Getting description attribute value from value type

Author
18 Aug 2006 1:40 PM
Smokey Grindle
Say I have an enumeration

Public Enum MyEnum
    <desctription("test 123") Test
    <description("My Val") Value
end enum

private MyValue as MyEnum = MyEnum.Text

now I want to get the description in code, i'm assumeing reflection, but
exactly how would I get that information about the description of the value
in MyValue? thanks!

Author
18 Aug 2006 3:30 PM
Larry Lard
Smokey Grindle wrote:
> Say I have an enumeration
>
> Public Enum MyEnum
>     <desctription("test 123") Test
>     <description("My Val") Value
> end enum

Real code please.


--
Larry Lard
larryl***@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Author
18 Aug 2006 3:46 PM
Smokey Grindle
there is no "Real code" I'm just asking how do you access a value of an
attribute for an item....

Show quoteHide quote
"Larry Lard" <larryl***@googlemail.com> wrote in message
news:4km4nqFct7k9U1@individual.net...
> Smokey Grindle wrote:
>> Say I have an enumeration
>>
>> Public Enum MyEnum
>>     <desctription("test 123") Test
>>     <description("My Val") Value
>> end enum
>
> Real code please.
>
>
> --
> Larry Lard
> larryl***@googlemail.com
> The address is real, but unread - please reply to the group
> For VB and C# questions - tell us which version
Author
18 Aug 2006 5:58 PM
Herfried K. Wagner [MVP]
"Smokey Grindle" <nospam@dontspamme.com> schrieb:
> Public Enum MyEnum
>    <desctription("test 123") Test
>    <description("My Val") Value
> end enum
>
> private MyValue as MyEnum = MyEnum.Text
>
> now I want to get the description in code, i'm assumeing reflection, but
> exactly how would I get that information about the description of the
> value in MyValue?

Adding descriptions to enumeration constants
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=enumdescription&lang=en>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
18 Aug 2006 6:00 PM
Smokey Grindle
thanks, that is exactly what I was looking for!

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:OSr$d$uwGHA.1296@TK2MSFTNGP02.phx.gbl...
> "Smokey Grindle" <nospam@dontspamme.com> schrieb:
>> Public Enum MyEnum
>>    <desctription("test 123") Test
>>    <description("My Val") Value
>> end enum
>>
>> private MyValue as MyEnum = MyEnum.Text
>>
>> now I want to get the description in code, i'm assumeing reflection, but
>> exactly how would I get that information about the description of the
>> value in MyValue?
>
> Adding descriptions to enumeration constants
> <URL:http://dotnet.mvps.org/dotnet/faqs/?id=enumdescription&lang=en>
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>