Is C# 4.0 Tuple covariant

前端 未结 2 428
误落风尘
误落风尘 2021-01-04 09:45

(I would check this out for myself, but I don\'t have VS2010 (yet))

Say I have 2 base interfaces:

IBaseModelInterface
IBaseViewInterface
2条回答
  •  我在风中等你
    2021-01-04 10:05

    Tuple is a class (well, a family of classes) - it's invariant by definition. As you mention later on, only interfaces and delegate types support generic variance in .NET 4.

    There's no ITuple interface that I'm aware of. There could be one which would be covariant, as the tuples are immutable so you only get values "out" of the API.

提交回复
热议问题