FormattableString.Invariant(FormattableString) Method

Definition

傳回結果字串,其引數是使用不因文化特性 (Culture) 而異的慣例來格式化。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

Parameters

formattable
FormattableString

要轉換為結果字串的物件。The object to convert to a result string.

Returns

String

使用不因文化特性 (Culture) 而異的慣例將目前執行個體格式化所產生的字串。The string that results from formatting the current instance by using the conventions of the invariant culture.

Exceptions

formattablenullformattable is null.

Remarks

此靜態方法可以透過下列語句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} }}")   

Applies to