FormattableString.Invariant(FormattableString) 方法

定义

返回一个结果字符串,其参数可以通过固定区域性的约定格式化。Returns a result string in which arguments are formatted by using the conventions of the invariant culture.

public:
 static System::String ^ Invariant(FormattableString ^ formattable);
public static string Invariant (FormattableString formattable);
static member Invariant : FormattableString -> string
Public Shared Function Invariant (formattable As FormattableString) As String

参数

formattable
FormattableString

要转换为结果字符串的对象。The object to convert to a result string.

返回

使用固定区域性的约定格式化当前实例生成的字符串。The string that results from formatting the current instance by using the conventions of the invariant culture.

异常

formattablenullformattable is null.

注解

此静态方法可在中C#通过以下语句导入:This static method can be imported in C# by the following statement:

using static System.FormattableString;  

using static 指令的范围内,可以使用固定区域性的约定通过代码(如下所示)来设置内插字符串的格式:Within the scope that using static directive, an interpolated string may be formatted using the conventions of the invariant culture by code such as the following:

Invariant($"{{ lat = {latitude}; lon = {longitude} }}")   

适用于