Is it safe to use the new C # features when creating for older versions of the .NET Framework?

I support the .NET 2.0 library (currently using Visual Studio 2013).

I used the code checking tool in the library code and was surprised when the tool suggested using a statement ??or lambdas instead of some code.

I was even more surprised when I applied the proposed changes, and the library was successfully built after that.

Why can the c library Target Frameworkinstalled on .NET Framework 2.0can be built with the new C # functions in this code?

Can I use the new C # features when creating for earlier versions of the .NET Framework? I mean, library users can only have the .NET Framework 2.0, and I want them to be able to use the library, even if I use lambdas in this code.

+4
source share
2 answers

.NET 2.0 and C # 2.0 are two different things. In your case, you may well have the .NET 2.0 library (which is oriented towards CLR 2.0) and use the C # 3.0 compiler, which supports, for example, lambda expressions.

So, you have to make the difference between the version of your compiler and the version of the CLR that you are targeting. Since you are using VS 2013, you can use newer versions of the compiler.

# .NET Framework?

, . - CLR 2.0 - CLR.

+6

, # , .net. , .

, # 3.0. . , # 3.0, .net 2.0. , lambdas .net 2.0.

, , .

, ??, # 2.0, .net 2.0.

+4

Source: https://habr.com/ru/post/1526040/


All Articles