Is very similar:
public class A<T> where T : B {
This can be used to restrict T to be a subclass or implementation of B (if B is an interface).
Alternatively, you can restrict T to a reference type, a value type, or require a default constructor:
where T : class // T must be a reference type where T : struct // T must be a value type where T : new()
source share