Getting attributes of Enum’s value

I would like to know if it is possible to get attributes of the enum values and not of the enum itself? For example, suppose I have the following enum: using System.ComponentModel; // for DescriptionAttribute enum FunkyAttributesEnum { [Description(“Name With Spaces1”)] NameWithoutSpaces1, [Description(“Name With Spaces2”)] NameWithoutSpaces2 } What I want is given the enum type, … Read more

Why does C# forbid generic attribute types?

This causes a compile-time exception: public sealed class ValidatesAttribute<T> : Attribute { } [Validates<string>] public static class StringValidation { } I realize C# does not support generic attributes. However, after much Googling, I can’t seem to find the reason. Does anyone know why generic types cannot derive from Attribute? Any theories? 8 s 8 Well, … Read more

Most Useful Attributes [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 8 years ago. Improve this question I know that attributes are extremely useful. There are some predefined ones such as [Browsable(false)] which … Read more