This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21152|Reply: 0

[Source] C# int to string with a comma for every three bits

[Copy link]
Posted on 11/8/2016 2:30:45 PM | | | |



1. Format currency (related to the system environment, Chinese system formats RMB by default, English system formats USD)
string. Format("{0:C}",0.2) Result: ¥0.20 (English OS result: $0.20)
The default format is to keep two decimal places after the decimal point, and if you need to retain one or more digits, you can specify the number of digits
string. Format("{0:C1}",23.15) result: ¥23.2 (interception will be automatically rounded)
Format multiple Object instances
string. Format("Market Price: {0:C}, Discounted Price {1:C}", 23.15, 19.82)
2. Format decimal numbers (format into a fixed number of digits, the number of digits cannot be less than before formatting, only support shaping)
string. Format("{0:D3}",23) result: 023
string. Format("{0:D2}",1223) The result is: 1223, (The precision specifier indicates the minimum number of digits required in the result string.) )
3. Numbers separated by semicolons, and specify the number of digits after the decimal point
string. Format("{0:N}", 14200) result: 14,200.00 (default is two decimal places)
string. Format("{0:N3}", 14200.2458) result: 14,200.246 (auto-rounding)
4. Formatting percentage
string. Format("{0:P}", 0.24583) result: 24.58% (two decimal places of the percent are reserved by default)
string. Format("{0:P1}", 0.24583) result: 24.6% (auto-rounding)
5. Zero placeholders and digital placeholders
string. Format("{0:0000.00}", 12394.039) result: 12394.04
string. Format("{0:0000.00}", 194.039) result: 0194.04
string. Format("{0:###.##}", 12394.039) result: 12394.04
string. format("{0:####.#}", 194.039) result: 194
The following explanation is difficult to understand, but you can understand it by testing the actual application.
Zero placeholders:
If the formatted value has a number where "0" appears in the format string, this number is copied to the resulting string. The position of the leftmost "0" before the decimal point and the position of the rightmost "0" after the decimal point determine the range of numbers that will always appear in the result string.
The "00" specifier makes the value round to the nearest number before the decimal point, where the zero digit is always rounded.
Digital placeholders:
If the formatted value has a number where the "#" appears in the format string, this number is copied to the resulting string. Otherwise, this location in the result string does not store any value.
Note that if "0" is not a significant figure, this specifier will never display the "0" character, even if "0" is the only number in the string. If "0" is a significant digit in the number displayed, the "0" character is displayed.
The "##" format string makes the value rounded to the nearest number before the decimal point, where zero is always rounded.
PS: Space placeholders
string. Format("{0,-50}", theObj); Format to 50 characters, the original character is aligned to the left, and the space is filled in if it is insufficient
string. Format("{0,50}", theObj); Format it into 50 characters, the original characters are aligned to the right, and if they are insufficient, fill in the spaces
6. Date formatting
string. Format("{0:d}",System.DateTime.Now) result: 2009-3-20 (month position is not 03)
string. Format("{0:D}",System.DateTime.Now) result: March 20, 2009
string. Format("{0:f}",System.DateTime.Now) result: 15:37, 20 March 2009 (UTC).
string. Format("{0:F}",System.DateTime.Now) result: 15:37:52, 20 Mar 2009
string. Format("{0:g}",System.DateTime.Now) result: 2009-3-20 15:38
string. Format("{0:G}",System.DateTime.Now) result: 2009-3-20 15:39:27
string. Format("{0:m}",System.DateTime.Now) result: March 20
string. Format("{0:t}",System.DateTime.Now) result: 15:41
string. Format("{0:T}",System.DateTime.Now) result: 15:41:50

For a more detailed explanation, please see Microsoft's explanation of this below, or check it on MSDN.
Microsoft MSDN method description for string.format:
Name Description
String.Format (String, Object) replaces the format item in the specified String with the text equivalent of the value of the specified Object instance.
String.Format (String, Object[]) replaces the format item in the specified String with the text equivalent of the value of the corresponding Object instance in the specified array.
String.Format (IFormatProvider, String, Object[]) replaces the format item in the specified String with a text equivalent of the value of the corresponding Object instance in the specified array. The specified parameters provide region-specific formatting information.
String.Format (String, Object, Object) replaces the format item in the specified String with the text equivalent of the value of the two specified Object instances.
String.Format (String, Object, Object, Object) replaces the format item in the specified String with the text equivalent of the value of the three specified Object instances.
Standard numeric format strings
Format specifier Name description
C or C
currency
The number is converted to a string that represents the amount of money. Transformations are controlled by the currency format information of the current NumberFormatInfo object.
The precision specifier indicates the number of decimal places required. If the precision specifier is omitted, the default currency precision given by the current NumberFormatInfo object is used.

D or d
Decimal numbers
Only integers support this format. The number is converted to a string of decimal numbers (0-9), preceded by a negative sign if the number is negative.
The precision specifier indicates the minimum number of digits required in the result string. If needed, fill the left side of that number with zeros to produce the number of numbers given by the precision specifier.

E or E
Scientific Notation (Exponent)
The number is converted to "-d.ddd... E+ddd" or "-d.ddd... e+ddd", where each "d" represents a number (0-9). If the number is negative, the string starts with a minus sign. There is always a number before the decimal point.
The precision specifier indicates the number of digits required after the decimal point. If the precision specifier is omitted, the default value, which is six decimal places, is used.
The case of the format specifier indicates whether the index is prefixed with an "E" or "e". The index is always made up of a positive or negative sign and a minimum of three digits. If desired, fill the index with zeros to meet the minimum three-digit requirement.

F or F
Fixed point
The numbers are converted to strings of the form "-ddd.dddd...", where each "d" represents a number (0-9). If the number is negative, the string starts with a minus sign.
The precision specifier indicates the number of decimal places required. If the precision specifier is ignored, the default numerical precision given by the current NumberFormatInfo object is used.

G or g
Regular
Depending on the type of number and the presence or absence of precision specifiers, numbers are converted to the most compact form of fixed-point or scientific notation. If the precision specifier is omitted or zero, the type of number determines the default precision, as shown in the following table.
Byte or SByte:3
Int16 or UInt16:5
Int32 or UInt32:10
Int64 or UInt64:19
Single:7
Double:15
Decimal:29
If the exponent is greater than -5 and less than the precision descriptor when the number is expressed in scientific notation, the fixed-point notation is used; Otherwise, scientific notation is used. If the requirement has a decimal point, and the tail zero is ignored, the result contains a decimal point. If a precision specifier exists and the number of significant digits of the result exceeds the specified precision, the excess trailing digits are removed by rounding.
There is an exception to this rule: if the number is Decimal and the precision specifier is omitted. In this case, the fixed-point notation is used totally and the tail zero is retained.
When using scientific notation, if the format specifier is "G", the exponent of the result is prefixed with "E"; If the format specifier is "g", the resulting exponent is prefixed with "e".

n or n
numbers
The number is converted to a string in the form "-d,ddd,ddd.dd...", where "-" indicates a negative number symbol (if desired), "d" indicates a number (0-9), ",", indicates a thousand separator between groups of numbers, "." Indicates a decimal point sign. The actual negative number pattern, number group size, thousand separator, and decimal separator are specified by the current NumberFormatInfo object.
The precision specifier indicates the number of decimal places required. If the precision specifier is ignored, the default numerical precision given by the current NumberFormatInfo object is used.

p or p
percentage
The number is converted to a string that represents a percentage, defined by the NumberFormatInfo.PercentNegativePattern or NumberFormatInfo.PercentPositivePattern property, which is used for negative numbers and positive numbers. The converted number is multiplied by 100 to represent as a percentage.
The precision specifier indicates the number of decimal places required. If the precision specifier is ignored, the default numerical precision given by the current NumberFormatInfo object is used.

R or r
Round-trip process
Only the Single and Double types support this format. The round-trip process specifier ensures that the value converted to a string is parsed again to the same value. When formatting a numerical value using this specifier, first test it in the regular format: Double with 15-bit precision and Single with 7-bit precision. If this value is successfully parsed back to the same value, it is formatted using a regular format specifier. However, if this value is not successfully analyzed as the same value, it is formatted like this: Double uses 17-bit precision and Single uses 9-bit precision.
While the precision specifier can be present here, it will be ignored. When using this specifier, the round-trip process takes precedence over precision.

X or X
Hex numbers
Only integers support this format. A string of numbers converted to hexadecimal numbers. The case of the format specifier indicates whether uppercase or lowercase characters are used for hexadecimal numbers greater than 9. For example, use "X" to produce "ABCDEF" and "X" to produce "abcdef".
The precision specifier indicates the minimum number of digits required in the result string. If needed, fill the left side of that number with zeros to produce the number of numbers given by the precision specifier.

Any other individual characters
(Unknown specifier)
(An unknown specifier will throw a runbook format exception.) )

Custom numeric format strings
Format specifier Name description
0
Zero placeholders
If the formatted value has a number where "0" appears in the format string, this number is copied to the resulting string. The position of the leftmost "0" before the decimal point and the position of the rightmost "0" after the decimal point determine the range of numbers that will always appear in the result string.
The "00" specifier makes the value round to the nearest number before the decimal point, where the zero digit is always rounded. For example, formatting 34.5 with "00" will yield the value 35.

#
Digital placeholders
If the formatted value has a number where the "#" appears in the format string, this number is copied to the resulting string. Otherwise, this location in the result string does not store any value.
Note that if "0" is not a significant figure, this specifier will never display the "0" character, even if "0" is the only number in the string. If "0" is a significant digit in the number displayed, the "0" character is displayed.
The "##" format string makes the value rounded to the nearest number before the decimal point, where zero is always rounded. For example, formatting 34.5 with "##" will yield a value of 35.

.
Decimal point
The first "." Characters determine the position of the decimal separator in the formatted value; Any other "." Characters are ignored.
The actual character used as the decimal separator is determined by the NumberDecimalSeparator property of the NumberFormatInfo that controls formatting.

,
Thousand separator and numeric scale conversion
The character can be used as a thousand separator specifier and a numeric scale conversion specifier.
Thousand separator specifier: If one or more "," characters are specified between two numeric placeholders (0 or #) to format the numeric integer bit, insert a group separator character between each group of numbers in the integer portion of the output.
The NumberGroupSeparator and NumberGroupSizes properties of the current NumberFormatInfo object determine which characters are used as number group separators and the size of each number group. For example, if you format the number 1000 with the string "#,#" and fixed locality, the output is "1,000".
Number Scale Conversion Specifier: If you specify one or more "," characters immediately to the left of an explicit or implicit decimal point, divide the number to be formatted by 1000 for each number scale specifier that occurs. For example, if you format the number 10000000000 with the string "0,", the output is "100".
You can use the thousand separator specifier and the numeric scale conversion specifier in the same format string. For example, if you format the number 100000000000 with the string #,0,,, and fixed locality, the output is "1,000".

%
Percentage placeholder
The appearance of the "%" character in the format string will cause the number to be multiplied by 100 before formatting. The appropriate symbol is inserted into the place where the number itself appears in the format string with "%". The percentage character used is determined by the current NumberFormatInfo class.

E0
E+0
E-0
e0
e+0
e-0
Scientific notation method
If any of the strings "E", "E+", "E-", "e", "e+" or "e-" appear in the format string and are followed by at least one "0" character, the numbers are formatted in scientific notation, inserting "E" or "e" between the number and the exponent. The number of "0" characters followed by the scientific notation indicator determines the minimum number of digits of the exponential output. The "E+" and "e+" formats indicate that the symbol characters (positive or negative) should always be placed before the index. The format "E", "E-", "e", or "e-" indicates that the symbol character is placed only before the negative exponent.

\
Transform the meaning of the symbol
In C# and C++, backslash characters make the next character in the format string interpreted as an escape sequence. It works with traditional formatting sequences like "\n" (line breaks).
In some languages, the escape itself must be followed by the escape when used as text. Otherwise, the compiler understands the character as an escape. Use the string "\\" to display "\".
Note that this escape is not supported in Visual Basic, but ControlChars provides the same functionality.

’ABC’
"ABC"
string
Characters quoted in single or double quotes are copied into the resulting string without affecting formatting.

;
Partial separator
“;” Characters are used to separate positive, negative, and zero parts of a format string.

other
All other characters
All other characters are copied into the resulting string without affecting formatting.

Standard DateTime format string
Format specifier Name description
d
Short date mode
Represents a custom DateTime format string defined by the current ShortDatePattern property.
For example, the custom format string used to fix the region is "MM/dd/yyyy".

D
Long date mode
Represents a custom DateTime format string defined by the current LongDatePattern property.
For example, the custom format string used to fix the region is "dddd, dd MMMM yyyy".

f
Full date/time mode (short time)
Represents a combination of long date (D) and short time (t) patterns, separated by spaces.

F
Full date/time mode (long time)
Represents a custom DateTime format string defined by the current FullDateTimePattern property.
For example, the custom format string used to fix the region is "dddd, dd MMMM yyyyy HH:mm:ss".

g
Regular Date/Time Mode (Short Time)
Represents a combination of short date (d) and short time (t) patterns, separated by spaces.

G
Regular Date/Time Mode (Long Time)
Represents a combination of short date (d) and long (T) modes, separated by spaces.

M or m
Month and day mode
Represents a custom DateTime format string defined by the current MonthDayPattern property.
For example, the custom format string used to fix the region is "MMMM dd".

o
Round-trip date/time mode
A custom DateTime format string that represents a pattern that uses time zone information. This pattern is dedicated to round-trip DateTime formatting, including the Kind property in text. Subsequent use of Parse or ParseExact with the correct Kind property value allows for reverse analysis of the formatted string.
The custom format string is "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK".
The pattern used for this specifier is the standard for definition. Therefore, it is always the same regardless of the regionality used or the format provider provided.

R or r
RFC1123 mode
Represents a custom DateTime format string defined by the current RFC1123Pattern property. The pattern is defined and the attributes are read-only. Therefore, it is always the same regardless of the regionality used or the format provider provided.
The definition format string is "ddd, dd MMM yyyyy HH':'mm':'ss 'GMT'".
Formatting does not modify the value of the DateTime object that is being formatted. Therefore, the application must convert the value to Coordinated Universal Time (UTC) before using this format specifier.

s
Sortable date/time mode; ISO 8601 compliant
Represents a custom DateTime format string defined by the current SortableDateTimePattern property. This pattern is a defined standard, and the properties are read-only. Therefore, it is always the same regardless of the regionality used or the format provider provided.
The custom format string is "yyyy'-'MM'-'dd'T'HH':'mm':'ss".

t
Short time mode
Represents a custom DateTime format string defined by the current ShortTimePattern property.
For example, a custom format string for fixing a region is "HH:mm".

T
Long Term Mode
Represents a custom DateTime format string defined by the current LongTimePattern property.
For example, the custom format string used to fix the region is "HH:mm:ss".

u
Universal sortable date/time mode
Represents a custom DateTime-formatted string defined by the current UniversalSortableDateTimePattern property. This pattern is a defined standard, and the properties are read-only. Therefore, it is always the same regardless of the regionality used or the format provider provided.
The custom format string is "yyyy'-'MM'-'dd HH':'mm':'ss'Z'".
Formatting dates and times without time zone conversion. Therefore, the application must convert the local date and time to Coordinated Universal Time (UTC) before using this format specifier.

U
Universal sortable date/time mode
Represents a custom DateTime format string defined by the current FullDateTimePattern property.
This mode is the same as the Full Date/Long Time (F) mode. However, formatting will act on the Coordinated Universal Time (UTC) equivalent to the DateTime object being formatted.

Y or y
Year and month pattern
Represents a custom DateTime format string defined by the current YearMonthPattern property.
For example, a custom format string used to fix a region is "yyyy MMMM".

Any other individual characters
(Unknown specifier)
Unknown specifiers will throw a runtime formatting exception.

Custom DateTime format string
Format specifier Description
d
Represent the mid-month date as a number from 1 to 31. The date of the one-digit number is set in a format without leading zeros. For more information about using a single format specifier, see Using a single custom format specifier.

dd
Represent the mid-month date as a number from 01 to 31. The date of the one-digit number is set in the format with leading zeros.

ddd
Representing the abbreviated name of a day of the week as defined in the current System.Globalization.DateTimeFormatInfo.AbbreviatedDayNames property.

dddd (plus any number of "d" specifiers)
Represents the full name of a day of the week as defined in the current System.Globalization.DateTimeFormatInfo.DayNames property.

f
Represents the highest significant bit of the second part.
Note that if the "f" format specifier is used alone and there are no other format specifiers, the specifier is considered to be the "f" standard DateTime format specifier (full date/time pattern). For more information about using a single format specifier, see Using a single custom format specifier.
When using this format specifier with the ParseExact or TryParseExact methods, the number of "f" format specifiers used indicates the highest significant digits in the part of the second to be analyzed.

ff
Represents the two most significant bits of the second part.

fff
Represents the three most significant bits of the second part.

ffff
Represents the four most significant bits of the second part.

fffff
Represents the five most significant bits of the second part.

ffffff
Represents the six most significant bits of the second part.

fffffff
Represents the seven most significant bits of the second part.

F
Represents the highest significant bit of the second part. If the bit is zero, no information is displayed. For more information about using a single format specifier, see Using a single custom format specifier.
When using this format specifier with the ParseExact or TryParseExact methods, the number of "F" format specifiers used indicates the maximum number of significant bits of the second portion to be analyzed.

FF
Represents the two most significant bits of the second part. But it doesn't show trailing zeros (or two zeros).

FFF
Represents the three most significant bits of the second part. But it doesn't show trailing zeros (or three zeros).

FFFF
Represents the four most significant bits of the second part. But it doesn't show trailing zeros (or four zeros).

FFFFF
Represents the five most significant bits of the second part. But it doesn't show trailing zeros (or five zeros).

FFFFFF
Represents the six most significant bits of the second part. But it doesn't show trailing zeros (or six zero bits).

FFFFFFF
Represents the seven most significant bits of the second part. But it doesn't show trailing zeros (or seven zero bits).

g or gg (plus any number of "g" specifiers)
Indicates a period or epoch (e.g. A.D.). If the date you want to format doesn't have an associated period or epoch string, ignore the specifier. For more information about using a single format specifier, see Using a single custom format specifier.

h
Represent hours as numbers from 1 to 12, i.e. hours are represented by a 12-hour clock, counting whole hours from midnight or noon. Therefore, a particular number of hours that pass after midnight cannot be distinguished from the same number of hours after noon. Hours are not rounded, and one-digit hours are set in format without leading zeros. For example, given a time of 5:43, this format specifier shows "5". For more information about using a single format specifier, see Using a single custom format specifier.

hh, hh (plus any number of "h" specifiers)
Represent hours as numbers from 01 to 12, i.e., hours are represented by the 12-hour clock, counting whole hours from midnight or noon. Therefore, a particular number of hours that pass after midnight cannot be distinguished from the same number of hours after noon. Hours are not rounded, and one-digit hours are set in a format with leading zeros. For example, given a time of 5:43, this format specifier shows "05".

H
Hours are expressed as numbers from 0 to 23, i.e. hours are represented by a 24-hour system starting from zero, counting hours from midnight. The number of hours with one-digit numbers is set to a format without leading zeros.

HH, HH (plus any number of "H" specifiers)
Hours are expressed as numbers from 00 to 23, i.e. hours are represented by a 24-hour system starting from zero, counting hours from midnight. The number of hours with one digit is set in a format with leading zeros.

K
Represents a different value of the DateTime.Kind property, i.e., "Local", "Utc", or "Unspecified". This specifier loops through the Kind value in text and preserves the time zone. If the Kind value is "Local", this specifier is equivalent to the "zzz" specifier and is used to display the local time offset, such as "-07:00". For "utc" type values, the specifier displays the character "Z" to indicate the UTC date. For the Unspecified type value, the specifier is equivalent to "(nothing).

m
Represent minutes as numbers from 0 to 59. Minutes represent the full number of minutes that have elapsed since the previous hour. The number of minutes for a one-digit number is set in a format without leading zeros. For more information about using a single format specifier, see Using a single custom format specifier.

mm, mm (plus any number of "m" specifiers)
Represent minutes as numbers from 00 to 59. Minutes represent the full number of minutes that have elapsed since the previous hour. The number of minutes for a single digit is set in a format with leading zeros.

M
Represent the month as a number from 1 to 12. The month of the one-digit number is set to a format without leading zeros. For more information about using a single format specifier, see Using a single custom format specifier.

MM
Represent the month as a number from 01 to 12. The month of the one-digit number is set in the format with leading zeros.

MMM
Represents the abbreviated name of the month as defined in the current System.Globalization.DateTimeFormatInfo.AbbreviatedMonthNames property.

MMMM
Represents the full name of the month as defined in the current System.Globalization.DateTimeFormatInfo.MonthNames property.

s
Represent seconds as numbers from 0 to 59. Seconds represent the whole number of seconds that have elapsed since the previous minute. The number of seconds for a one-digit number is set in a format without leading zeros. For more information about using a single format specifier, see Using a single custom format specifier.

ss, ss (plus any number of "s" specifiers)
Represent seconds as numbers from 00 to 59. Seconds represent the whole number of seconds that have elapsed since the previous minute. The number of seconds for a single digit is set in a format with leading zeros.

t
Represents the first character of the A.M./P.M. indicator defined in the current System.Globalization.DateTimeFormatInfo.AMDesignator or System.Globalization.DateTimeFormatInfo.PMDesignator properties. If the number of hours in the time being formatted is less than 12, the A.M. indicator is used; Otherwise, use the P.M. designator. For more information about using a single format specifier, see Using a single custom format specifier.

tt, tt (plus any number of "t" specifiers)
Representing the A.M./P.M. indicator as defined in the current System.Globalization.DateTimeFormatInfo.AMDesignator or System.Globalization.DateTimeFormatInfo.PMDesignator properties. If the number of hours in the time being formatted is less than 12, the A.M. indicator is used; Otherwise, use the P.M. designator.

y
Represent the year as a maximum of two digits. If the year is more than two digits, only the two-digit low number is shown in the results. If the year is less than two digits, the number is set in format without leading zeros. For more information about using a single format specifier, see Using a single custom format specifier.

yy
Represent the year as a two-digit number. If the year is more than two digits, only the two-digit low number is shown in the results. If the year is less than two digits, fill that number with leading zeros to make it double digits.

yyy
Represent the year as a three-digit number. If the year is more than three digits, only the low three digits will be shown in the results. If the year is less than three digits, fill the number with a leading zero to bring it to three digits.
Note that for the Thai Buddhist calendar, where the year can be five digits, this format specifier will display all five digits.

yyyy
Represent the year as a four-digit number. If the year is more than four digits, only the low four digits are shown in the results. If the year is less than four digits, fill that number with a leading zero to bring it to four digits.
Note that for the Thai Buddhist calendar, where the year can be five digits, this format specifier will render all five digits.

yyyyy (plus any number of "y" specifiers)
Represent the year as a five-digit number. If the year is more than five digits, only the low five digits are shown in the results. If the year is less than five digits, fill that number with leading zeros to bring it to five digits.
If there is an additional "y" specifier, fill the number with the required number of leading zeros to reach the number of "y" descriptors.

z
Represents the signed time zone offset from the system time to Greenwich Time (GMT) measured in hours. For example, a computer located in the Pacific Standard Time Zone has an offset of "-8".
The offset is always displayed as having a leading symbol. The plus sign (+) indicates that the hours are earlier than GMT, and the minus sign (-) indicates that the hours are later than GMT. The offset ranges from –12 to +13. The offset of the one-digit number is set to a format without leading zeros. The offset is affected by daylight saving time. For more information about using a single format specifier, see Using a single custom format specifier.

zz
Represents the signed time zone offset from the system time to Greenwich Time (GMT) measured in hours. For example, a computer located in the Pacific Standard Time Zone has an offset of "-08".
The offset is always displayed as having a leading symbol. The plus sign (+) indicates that the hours are earlier than GMT, and the minus sign (-) indicates that the hours are later than GMT. The offset ranges from –12 to +13. The offset of the one-digit number is set to the format with leading zeros. The offset is affected by daylight saving time.

zzz, zzz (plus any number of "z" specifiers)
Represents the signed time zone offset from Greenwich Time (GMT) measured in hours and minutes from the system time. For example, a computer located in the Pacific Standard Time Zone has an offset of "-08:00".
The offset is always displayed as having a leading symbol. The plus sign (+) indicates that the hours are earlier than GMT, and the minus sign (-) indicates that the hours are later than GMT. The offset ranges from –12 to +13. The offset of the one-digit number is set to the format with leading zeros. The offset is affected by daylight saving time.

:
The time separator defined in the current System.Globalization.DateTimeFormatInfo.TimeSeparator property to distinguish between hours, minutes, and seconds.

/
The date separator defined in the current System.Globalization.DateTimeFormatInfo.DateSeparator property to distinguish between year, month, and day.

"
Strings in quotation marks (quotes). Displays the text value of any string between two quotation marks ("). Use an escape (\) before each quote.

'
Strings in quotation marks (apostrophes). Displays the text value of any string between two apostrophe (') characters.

%c
When a custom DateTime format string contains only the custom format specifier "c", it indicates the result associated with that custom format specifier. That is, to use the custom format specifiers "d", "f", "f", "h", "m", "s", "t", "y", "z", "H", or "M" alone, specify "%d", "%f", "%F", "%h", "%m", "%s", "%t", "%y", "%z", "%H", or "%M". For more information about using a single format specifier, see Using a single custom format specifier.

\c
Transform the meaning of the symbol. When the character "c" is preceded by an escape (\), the character is displayed as text. To insert the backslash character itself into the result string, use two escapes ("\\").

Any other character
All other characters are copied into the resulting string without affecting formatting.

Enumerate format strings
Format String results
G or g
If possible, display the enum as a string value, otherwise the integer value of the current instance. If the Flags property is set in the enumeration definition, the string values for each valid item are concatenated and the values are separated by commas. If the Flags property is not set, the invalid value is displayed as a numeric item.

F or F
If possible, display the enumeration as a string value. If the values can be displayed entirely as the sum of the enum items (even if the Flags attribute is not provided), the string values for each valid item are concatenated and the values are separated by commas. If the value cannot be determined entirely by the enumeration term, format the value as an integer value.

D or d
Display the enum as an integer value in the shortest possible representation.

X or X
Displays the enum as a hexadecimal value. Represent values as having leading zeros as needed to ensure that the value is at least eight bits long





Previous:H5 utilizes localstorage to store JSON objects to arrays
Next:ef uses System.Data.Entity.DbFunctions.DiffDays to query the data for the current day and yesterday
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com