使用(某些)拉姆达EX pressions当面向.NET 2.0? [英] Use (certain) lambda expressions when targeting .NET 2.0?

查看:125
本文介绍了使用(某些)拉姆达EX pressions当面向.NET 2.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ReSharper的建议我们改变:

ReSharper suggests we change:

System.Net.ServicePointManager.ServerCertificateValidationCallback +=
    delegate(object sender, X509Certificate certificate, X509Chain chain,
        SslPolicyErrors sslPolicyErrors)
{
    return true;
};

进入:

System.Net.ServicePointManager.ServerCertificateValidationCallback +=
    (sender, certificate, chain, sslPolicyErrors) => true;

这看起来有点清洁。但是,我们的目标是.NET 2.0。这仍然是我们应该做的?

It looks a bit cleaner. But we are targeting .NET 2.0. Is this still something we should do?

推荐答案

您应该选择其中哪些你preFER最。在C#3.0中引入的所有功能(如LAMBDA EX pression,扩展方法和LINQ)是建立在2.0 .NET运行库。所以你可以开发使用C#3.0和运行时的2.0运行它。

You should choose which of them you prefer the most. In C# 3.0 all features introduced (such as Lambda expression, extension methods and LINQ) are build on the 2.0 .NET runtime. So you can develop using C#3.0 and run it on the 2.0 of the runtime.

只要你的编译器的可以处理C#3.0,你可以使用所有新的C#3.0的功能。我所知道的唯一的例外是,如果你使用防爆pression树,你可能需要使用.NET 2.0 SP1,因为一些在CLR该服务包中的修补程序需要做出EX pression树正常工作。

As long as your compiler can handle C#3.0 you can use all the new C#3.0 features. The only exception I know of is that if you use Expression trees you'd need to use .NET 2.0 SP1 because some of the bug fixes in the CLR for that service pack is needed to make expression trees work properly.

这篇关于使用(某些)拉姆达EX pressions当面向.NET 2.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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