更新时间:2022-01-25 08:40:58
不幸的是,返回类型必须匹配。您正在寻找的被称为返回类型协方差什么和C#不支持。
Unfortunately, the return type must match. What you are looking for is called 'return type covariance' and C# doesn't support that.
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=90909
埃里克利珀,在C#编译器团队的高级开发人员,提到在他的博客,他们不打算支持的返回类型协方差。
Eric Lippert, senior developer on C# Compiler team, mentions on his blog that they don't plan to support return type covariance.
这种差异被称为
返回类型协方差。正如我
在这个系列中提到的早期,(一)
这个系列是不是那种
方差,和(b)我们没有计划
C#实现那种方差。
"That kind of variance is called "return type covariance". As I mentioned early on in this series, (a) this series is not about that kind of variance, and (b) we have no plans to implement that kind of variance in C#. "
http://blogs.msdn.com/ericlippert/archive/2008/05/07/covariance-and-contravariance-part-twelve-to-infinity-but-not-beyond.aspx
这是值得一读的协变和逆变Eric的文章。
It's worth reading Eric's articles on covariance and contravariance.
http://blogs.msdn.com/ericlippert/archive/tags/Covariance+and+Contravariance/default.aspx