How to get an attribute of an enum element ?

H

Herve Bocuse

Hi,

Here is a wll known enum :

[Flags]
public enum ControlStyles
{
// Fields
AllPaintingInWmPaint = 0x2000,
CacheText = 0x4000,
ContainerControl = 1,
[Obsolete("Use OptimizedDoubleBuffer instead")]
DoubleBuffer = 0x10000,
EnableNotifyMessage = 0x8000,
FixedHeight = 0x40,
FixedWidth = 0x20,
Opaque = 4,
OptimizedDoubleBuffer = 0x20000,
ResizeRedraw = 0x10,
Selectable = 0x200,
StandardClick = 0x100,
StandardDoubleClick = 0x1000,
SupportsTransparentBackColor = 0x800,
UserMouse = 0x400,
UserPaint = 2,
UseTextForAccessibility = 0x40000
}

Having a variable of this type, how can I know that "DoubleBuffer" is
obsolete ? i.e. how to get the ObsoleteAttribute of this particular
element ?

Thank you

Herve
 
H

Herve Bocuse

oops, got it.
Just by using GetField on the enum type and then GetCustomAttribute on
the field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top