FormattableString.Format 属性

定义

返回复合格式字符串。Returns the composite format string.

public:
 abstract property System::String ^ Format { System::String ^ get(); };
public abstract string Format { get; }
member this.Format : string
Public MustOverride ReadOnly Property Format As String

属性值

String

复合格式字符串。The composite format string.

注解

复合格式字符串由零个或多个固定文本与一个或多个格式项混合组成,它们由用方括号分隔的索引号指示 (例如 {0}) 。A composite format string consists of zero or more runs of fixed text intermixed with one or more format items, which are indicated by an index number delimited with brackets (for example, {0}). 每个格式项的索引对应于组合格式字符串之后的对象列表中的一个参数。The index of each format item corresponds to an argument in an object list that follows the composite format string. 例如,在以下语句中:For example, in the following statement:

String.Format("Name = {0}, hours = {1:hh}", name, DateTime.Now);
String.Format("Name = {0}, hours = {1:hh}", name, DateTime.Now)

复合格式字符串为 "Name = {0}, hours = {1:hh}"the composite format string is "Name = {0}, hours = {1:hh}".

适用于

另请参阅