C # placeholder usage tutorial,
[\ N \ r] cannot match spaces during regular expression matching. [\ n \ r] can only match line breaks, and line breaks are placeholders, there is no length.
To match blank characters (including spaces, tabs, and page breaks), \ s, spaces, and tabs (that is, the blank space generated by the tab key) are all long.
C # There are also placeholder applications when formatting strings
String. Format ("{0}, {1}", "Match 0", "match 1 ")
{0} and {1} are placeholders in the string.
C # There are some special format identifiers used to format some special string formats
Letter meaning
Bytes -----------------------------------------------------------------------------------
C or c Currency format
D or d Decimal in Decimal format (do not confuse the Decimal data type with. Net)
E or e Exponent index format
Fixed precision format of F or f Fixed point
Common G or g General formats
N or n are separated by commas (,). For example, 1234 is changed to 1,234.
P or p Percentage percentile format
R or r Round-trip Round (only for floating point numbers) Ensure that a number can be converted back to the same number after being converted into a string
X or x Hex hexadecimal format
Example:
Static void Main ()
{
Int I = 12345;
Console. WriteLine ("{0: C}", I); // currency
Console. WriteLine ("{0: D}", I); // decimal number
Console. WriteLine ("{0: E}", I); // method of science and technology
Console. WriteLine ("{0: F}", I); // floating point representation
Console. WriteLine ("{0: G}", I); // G or g General common format
Console. WriteLine ("{0: N}", I); // N or n separated by commas (,)
}
Bytes -----------------------------------------------------------------------------------
D MM/dd/yyyy 1_datepattern (short date mode)
D dddd, MMMM dd, yyyy LongDatePattern (long date mode)
F dddd, MMMM dd, yyyy HH: mm Full date and time (long date and short time) (Full date and time mode)
F dddd, MMMM dd, yyyy HH: mm: ss FullDateTimePattern (long date and long time)
G mm/dd/yyyy HH: mm General (short date and short time) (General mode, short date and short time)
G mm/dd/yyyy HH: mm: ss General (short date and long time) (General mode, short date and long time)
M, m mmmm dd MonthDayPattern (monthly/daily Mode)
R, R ddd, dd MMM yyyy, HH ': 'mm': 'ss' gmt' RFC1123Pattern (RFC1123 Mode)
S yyyy-MM-dd HH: mm: ss SortableDateTimePattern (conforms to ISO 8601) using local time (use the sorting mode of local time)
T hh: mm ShortTimePattern (short time mode)
T hh: mm: ss LongTimePattern (long time mode)
U yyyy-MM-dd HH: mm: ss UniversalSortable-DateTimePattern (conforms to ISO 8601) using universal time (General sorting Mode)
U dddd, MMMM dd, yyyy, HH: mm: ss UniversalSortable-DateTimePattern (General sortable Mode)
Y, y mmmm, yyyy YearMonthPattern (yyyy)
Example:
Static void Main ()
{
Console. WriteLine ("{0: D}", DateTime. Now); // output to day
Console. WriteLine ("{0: y}", DateTime. Now); // output to month
Console. WriteLine ("{0: m}", DateTime. Now); // obtain the month
Console. WriteLine ("{0: T}", DateTime. Now); // obtain the duration in seconds.
Console. WriteLine ("{0: t}", DateTime. Now); // take a short time to minute
Console. WriteLine ("{0: tt}", DateTime. Now); // check whether the image is displayed in the morning or afternoon.
}