Does C# 7.0 work for .NET 4.5?

Let’s go through the features new in C# 7.0: Tuples: The System.ValueTuple package has a version for the portable-net40+sl4+win8+wp8 profile. That means it is usable on .Net 4.0. (Not sure why dependencies list only .Net 4.5.) If you wanted to use tuples on even lower versions of .Net, it should still work, as long as … Read more

Predefined type ‘System.ValueTuple´2´ is not defined or imported

For .NET 4.6.2 or lower, .NET Core 1.x, and .NET Standard 1.x you need to install the NuGet package System.ValueTuple: Install-Package “System.ValueTuple” Or using a package reference in VS 2017: <PackageReference Include=”System.ValueTuple” Version=”4.4.0″ /> .NET Framework 4.7, .NET Core 2.0, and .NET Standard 2.0 include these types.

Local function vs Lambda C# 7.0

This was explained by Mads Torgersen in C# Design Meeting Notes where local functions were first discussed: You want a helper function. You are only using it from within a single function, and it likely uses variables and type parameters that are in scope in that containing function. On the other hand, unlike a lambda … Read more

What’s the difference between System.ValueTuple and System.Tuple?

What are ValueTuples and why not Tuple instead? A ValueTuple is a struct which reflects a tuple, same as the original System.Tuple class. The main difference between Tuple and ValueTuple are: System.ValueTuple is a value type (struct), while System.Tuple is a reference type (class). This is meaningful when talking about allocations and GC pressure. System.ValueTuple … Read more

How to use C# 7 with Visual Studio 2015?

You can replace the compiler shipped with Visual Studio for a C# 7-enabled version by installing the Nuget package Microsoft.Net.Compilers: Referencing this package will cause the project to be built using the specific version of the C# and Visual Basic compilers contained in the package, as opposed to any system installed version. There is no … Read more