FormattableString FormattableString FormattableString FormattableString Class

定義

代表複合格式字串以及要格式化的引數。Represents a composite format string, along with the arguments to be formatted.

public ref class FormattableString abstract : IFormattable
public abstract class FormattableString : IFormattable
type FormattableString = class
    interface IFormattable
Public MustInherit Class FormattableString
Implements IFormattable
繼承
FormattableStringFormattableStringFormattableStringFormattableString
實作

備註

複合格式字串是由混合索引替代符號 (Placeholder) 的固定文字所組成 (這些符號稱為對應至清單內物件的格式項目)。A composite format string consists of fixed text intermixed with indexed placeholders, called format items, that correspond to the objects in the list. 格式作業產生的結果字串是由原始固定文字所組成,這些固定文字混合了清單中代表物件的字串。The formatting operation yields a result string that consists of the original fixed text intermixed with the string representation of the objects in the list. 複合格式是由String.FormatConsole.WriteLineStringBuilder.AppendFormat等方法所支援。Composite formatting is supported by methods such as String.Format, Console.WriteLine, and StringBuilder.AppendFormat. 如需複合格式的詳細資訊, 請參閱複合格式For more information on composite formatting, see Composite Formatting.

實例可能是來自或 Visual Basic 中的內C#插字串所造成。 FormattableStringA FormattableString instance may result from an interpolated string in C# or Visual Basic.

建構函式

FormattableString() FormattableString() FormattableString() FormattableString()

執行個體化 FormattableString 類別的新執行個體。Instantiates a new instance of the FormattableString class.

屬性

ArgumentCount ArgumentCount ArgumentCount ArgumentCount

取得要格式化的引數數目。Gets the number of arguments to be formatted.

Format Format Format Format

傳回複合格式字串。Returns the composite format string.

方法

CurrentCulture(FormattableString) CurrentCulture(FormattableString) CurrentCulture(FormattableString) CurrentCulture(FormattableString)

傳回結果字串,其引數會使用目前文化特性的慣例來格式化。Returns a result string in which arguments are formatted by using the conventions of the current culture.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetArgument(Int32) GetArgument(Int32) GetArgument(Int32) GetArgument(Int32)

傳回在指定索引位置處的引數。Returns the argument at the specified index position.

GetArguments() GetArguments() GetArguments() GetArguments()

傳回物件陣列,其中包含一或多個要格式化的物件。Returns an object array that contains one or more objects to format.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
Invariant(FormattableString) Invariant(FormattableString) Invariant(FormattableString) Invariant(FormattableString)

傳回結果字串,其引數是使用不因文化特性 (Culture) 而異的慣例來格式化。Returns a result string in which arguments are formatted by using the conventions of the invariant culture.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回使用目前文化特性 (Culture) 的格式化慣例將複合格式字串及其引數格式化所產生的字串。Returns the string that results from formatting the composite format string along with its arguments by using the formatting conventions of the current culture.

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

傳回使用指定文化特性 (Culture) 的格式化慣例將複合格式字串及其引數格式化所產生的字串。Returns the string that results from formatting the composite format string along with its arguments by using the formatting conventions of a specified culture.

明確介面實作

IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider)

傳回使用指定文化特性 (Culture) 的格式化慣例將格式字串及其引數格式化所產生的字串。Returns the string that results from formatting the format string along with its arguments by using the formatting conventions of a specified culture.

適用於

另請參閱