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
实现

注解

复合格式字符串由固定文本和索引占位符混和组成,其中索引占位符称为格式项,对应于列表中的对象。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.WriteLine,和StringBuilder.AppendFormatComposite formatting is supported by methods such as String.Format, Console.WriteLine, and StringBuilder.AppendFormat. 有关复合格式设置的详细信息,请参阅复合格式设置For more information on composite formatting, see Composite Formatting.

一个FormattableString实例可能会导致从 C# 或 Visual Basic 中的内插字符串。A 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)
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)

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

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

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

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

返回使用当前区域性的格式化约定格式化复合格式字符串及其参数生成的字符串。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)

返回使用指定区域性的格式化约定格式化复合格式字符串及其参数生成的字符串。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)

返回使用指定区域性的格式化约定格式化格式字符串及其参数生成的字符串。Returns the string that results from formatting the format string along with its arguments by using the formatting conventions of a specified culture.

适用于

另请参阅