It is valid (ie. it compiles and runs) to put an attribute on the generic parameter for a class or a method:

public class MyClass<[My] T>
{
    private void MyMethod<[My] T>()
    {}
}

public class MyAttribute : Attribute
{}

I've never seen this used, and am struggling to come up with a reason as to why you would want to.

Is it just a quirk/side-effect of the language specification, or is there a valid/useful reason to put an attribute in this position?

Edit
Report