C# Interpolated Strings in older .NET frameworks

2015-09-09

When targeting a .NET 4.0 or 4.5 project it's not possible by default to use the Interpolated Strings and their FormattableString and IFormattable counterparts. By default

But, this is only because these two types didn't ship with the older version of the .NET Framework. If you make sure these classes are available to the C#6 compiler, it will happily produce an assembly which is compatible with the older versions of the .NET framework, since these interpolated strings are a language feature and not dependent on the Common Language Runtime.

You'll need these classes to pass a CultureInfo in order to satisfy Code Analysis 1305.

Someone beat me to creating a NuGet Package of the classes required, which makes this as simple as running:

install-package StringInterpolationBridge
 

Search This Blog

Loading...

Most Reading