The new string interpolation style in Visual Studio 2015 is this:
Dim s = $\"Hello {name}\"
But if I use this the code analysis tells me I brea
Microsoft has made it easier to use string interpolation and comply with CA1305: Specify IFormatProvider.
If you are using C# 6 or later, you have access to the using static directive.
In addition, the static method FormattableString.Invariant
is available for .NET Standard 1.3, .NET Core 1.0 and .NET Framework 4.6 and later. Putting the two together allows you to do this:
using static System.FormattableString;
string name = Invariant($"Hello {name}");
If, however, your goal is for the interpolation to be done via the current culture, then a companion static method FormattableString.CurrentCulture
is proposed in .NET Core 3.0 (currently, Preview 5):
using static System.FormattableString;
string name = CurrentCulture($"Hello {name}");