Standard numeric format string usage instructions and examples

Source: Internet
Author: User
Tags integer numeric
Standard | string//Standard numeric format string usage instructions and examples
Class NumberFormat
{
static void Main ()
{
{Index[,alignment][:format]}
Index-A zero-based integer that indicates the element to be formatted in the object list.
Alignment-An optional integer that indicates the minimum width and the insufficient portion is padded with spaces. Negative numbers indicate left alignment and positive numbers indicate right alignment.
Format-formatting string. The standard numeric format string takes the form of "Axx", and A is a single letter, as described below:
C-Currency, XX indicates number of decimal places
D-Decimal, XX indicates the number of significant digits, less than 0 padding, only for integers
X-16 binary, using the same D
e-index, XX indicator decimal places
F-Fixed point, xx indicates decimal places
n-digit, output thousand separator, rest with F
G-General, XX indicates the number of significant digits, using the shorter of E or F
P-Percent, XX indicates number of decimal places
For example, the output of the following statement is: "|¥-5.00|-05| -05|-5.0 |-500.00%|12345.7|12,345.7| "
System.Console.WriteLine ("|{ 0:c}| {0:d2}| {0,4:d2}| {0,-5:f1}| {0:p2}| {1:f1}| {1:n1}| ",-5, 12345.67);
}
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.