开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜