Derivation Constraint
using System;
public class Starter {
public static void Main() {
// good
MyClass<XClass, YClass> obj = new MyClass<XClass, YClass>();
// good
MyClass<XClass, WClass> obj2 = new MyClass<XClass, WClass>();
// bad
MyClass<WClass, YClass> obj3 = new MyClass<WClass, YClass>();
}
}
public class MyClass<K, V>
where K : XClass
where V : YClass {
}
public class XClass {
}
public class YClass {
}
public class WClass : YClass {
}
Related examples in the same category