How to get an attribute of an enum element ?

  • Thread starter Thread starter Herve Bocuse
  • Start date Start date
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
 
oops, got it.
Just by using GetField on the enum type and then GetCustomAttribute on
the field.
 
Back
Top