Showing posts with label attributes. Show all posts
Showing posts with label attributes. Show all posts

Friday, June 8, 2012

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
{

}

Sunday, May 27, 2012

Most Useful Attributes in C#


I know that attributes are extremely useful. There are some predefined ones such as [Browsable(false)] which allows you to hide properties in the properties tab. Here is a good question explaining attributes: .NET: What are attributes?