协方差此外,在3.5 / 2.0? [英] Covariance Also in 3.5 / 2.0?

查看:124
本文介绍了协方差此外,在3.5 / 2.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

奇怪的问题...

从伊夫例如实施协方差。

Ive implemented covariance from example .

我的目标FW为4.0。

My target FW is 4.0.

如何过。我想看看如果失败3.5 / 2 - >,但它不会。

How ever . I wanted to see if it fails on 3.5 /2 -> but it wont.

这是不能忽视的,因为协方差为FW4.0。

It cant be since covariance is from FW4.0.

更改为3.0,制作并看到后:(+在运行时不会失败)

After changing to 3.0 i Build and see : (+wont fail on runtime)

推荐答案

协方差框架3的支持,但是在编译器中没有实现。您正在使用的编译器4目标框架3。

Covariance was supported in framework 3, but not implemented in the compiler. You are using compiler 4 targeting framework 3.

这是提到在埃里克利珀博客后,我去看看我能找到它。

This is mentioned in an Eric Lippert blog post, I'll see if I can find it..

修改

要进一步明确,:公共语言运行库和C#编译器(Csc.exe)是两个不同的东西。协变和逆变凡在2.0版中引入的CLR。他们没有被引入到C#,直到第4版您正在使用的编译器4来版订做3 IL这就是为什么它的工作原理。

To further clarify,: The Common Language Runtime and the C# compiler (csc.exe) are two separate things. Covariance and Contravariance where introduced to the CLR at version 2.0. They were not introduced to C# until version 4. You are using Compiler 4 to build version 3 IL which is why it works.

这篇关于协方差此外,在3.5 / 2.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆