C# Generic - Any way to declare T has an attribute?
[MyCustomClassAttribute]
public class Foo
{
}
public class Bar<T>
where T : ??
{
public T FooInstance;
}
I'm pretty sure this is impossible, but just thought I'd check. Any way to mak开发者_C百科e it so that T has to have a [MyCustomClassAttribute]
on it?
I am afraid this is impossible. Here's a list of all the possible generic constraints you could use.
精彩评论