C # Generic - Any way to declare a T has an attribute?

[MyCustomClassAttribute] public class Foo { } public class Bar<T> where T : ?? { public T FooInstance; } 

I'm sure this is not possible, but just thought that I would check. Any way to make this so that T has [MyCustomClassAttribute] on it?

+6
source share
1 answer

I am afraid that this is impossible. Here is a list of all possible common restrictions that you could use.

+5
source

Source: https://habr.com/ru/post/889894/


All Articles