我在第 9 channel 看了一段关于它的视频,但我并没有真正理解它。
有人可以给我一个简单易懂的例子吗?在那之后可能如何在实践中使用它?
最佳答案
你可能想看看这个博客,他解释得很好,但我认为需要更多的例子来为人们澄清,因为这进入了一个非常难以理解的领域,但是,文章下面的引述很好地总结了这一点。
http://hestia.typepad.com/flatlander/2008/12/c-covariance-and-contravariance-by-example.html
"covariance and contravariance" means that you can now pass inexact generic types when it's safe to do so, just as you can pass inexact argument types when it's safe to do so.
关于c# - 了解 C# 4.0 中的协变和逆变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1724919/