, # .NET Framework. # Framework, . , - .
, # 5.0 async - await .Net 4.0, Microsoft.Bcl.Async.
, # 6.0 , . :
string s = $"pie is {3.14}";
Console.WriteLine(s);
:
string s = string.Format("pie is {0}", 3.14);
Console.WriteLine(s);
.Net 4.5.
, , IFormattable FormattableString. , :
IFormattable formattable = $"pie is {3.14}";
Console.WriteLine(formattable.ToString(null, CultureInfo.InvariantCulture));
Console.WriteLine(formattable.ToString(null, new CultureInfo("cs-CZ")));
:
IFormattable formattable = FormattableStringFactory.Create("pie is {0}", 3.14);
Console.WriteLine(formattable.ToString(null, CultureInfo.InvariantCulture));
Console.WriteLine(formattable.ToString(null, new CultureInfo("cs-CZ")));
.Net 4.6, .Net 4.5
CS0518: 'System.Runtime.CompilerServices.FormattableStringFactory'
, :
namespace System.Runtime.CompilerServices
{
class FormattableStringFactory
{
public static IFormattable Create(string format, params object[] args) => null;
}
}
, NullReferenceException.
, StringInterpolationBridge .