Use (specific) lambda expressions when configuring .NET 2.0?

ReSharper suggests changing:

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

AT:

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

It looks a little cleaner. But we focus on .NET 2.0. Is this something else that we should do?

+6
c # lambda
Jul 27 '10 at 8:29
source share
2 answers

You must choose which one you prefer the most. In C # 3.0, all functions introduced (such as a Lambda expression, extension methods, and LINQ) are based on the .NET.NET runtime. This way you can develop using C # 3.0 and run it on 2.0 from the runtime.

While your compiler can handle C # 3.0, you can take advantage of all the new C # 3.0 features. The only exception that I know of is that if you use expression trees, you need to use .NET 2.0 SP1, because some CLR bug fixes for this service pack are necessary for the expression trees to work correctly.

+11
Jul 27 '10 at 9:58 on
source share

You can use it if you use VS2008 (or newer) for development. Lambda expressions are a feature of C #, not a .Net Framework function.

+8
Jul 27 '10 at 8:34
source share



All Articles