C# 6 Features: CLR Version

by Joseph on Jan 30th in .Net, C#, Visual Studio

Continuing in our C# 6 Features Series…

One of the neat things about C# 6 is that it is backwards compatible to previous versions of .Net.

Language Versions are not identical to .Net Common Language Runtime (CLR) versions – which can produce a little bit of confusion. As of today (January 30, 2016), the current .Net CLR runtime is 4.6.1. The current version of the C# Language Specification is 6.

As long as you have Visual Studio 2015 installed, you can write code using the C# 6 features, then target .Net 4, and compile your application.

The only feature that isn’t available out of the box is something called IFormattableString – but that can actually be added in using something like this:

[gist id=”2dce22c415eb824c2ded” file=”Program.cs”]

The trick is knowing what the feature does. String Interpolation, for instance, compiles down to String.Format() – and I was able to run a .Net 2 Console Application with the C# 6 String Interpolation feature.

[gist id=”cf1e483aa9d25dc76196″ file=”StringInterpDotNet2.cs”]

Play around with this – let me know your results!

Other Posts In Series

Leave a Reply

Powered By Wordpress Designed By Ridgey