Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

c# - Use (certain) lambda expressions when targeting .NET 2.0?

ReSharper suggests we change:

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

Into:

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...