类型参数相互定义? class A<T1, T2> 其中 T1 : Foo 其中 T2 : T1

Type parameters defining each other? class A<T1, T2> where T1 : Foo where T2 : T1

是否

class A<T1, T2>
    where T1 : Foo
    where T2 : T1

有实际用例吗?

有什么区别
class A<T1, T2>
    where T1 : Foo
    where T2 : Foo

?实际改变了什么?

涉及方差时是否一样?

区别在于 T2 不能只是任何 Foo 它必须是从 T1.

派生的 Foo

例如

public class Foo{}
public class Foo1 : Foo {}
public class Foo2 : Foo {}
public class Foo12 : Foo1 {}
public class A<T1,T2> where T1: Foo where T2 : T1 {}

将允许

var a = new A<Foo1, Foo12>()

但不是

var a  = new A<Foo1, Foo2>()

这也意味着您可以安全地将 T2 类型的对象转换为 T1

Is it the same when variance is involved?

方差只与接口有关。