C # format the output number

Source: Internet
Author: User
Class program {static void main (string [] ARGs) {console. writeline ("Digital formatting output"); formatenumericalvalue (99999); console. readkey ();}/** Number Format output * C or C monetization format, by default, the currency symbol of the country and region set by the computer is used to represent * E or E scientific notation to represent * D or D formatted decimal representation * f or F formatted to output * n or N basic using decimal formatting. value format (with comma) * X or X hexadecimal representation * g or G format as a fixed point or exponential representation */static void formatenumericalvalue (int32 nvalue) {console. writeline ("formatting output {0}", nvalue); console. writeline ("C, monetization output: {0: c}", nvalue); console. writeline ("D9, formatted decimal output: {0: D9}", nvalue); console. writeline ("e, power notation {0: e}", nvalue); console. writeline ("f, decimal Notation: {0: F3}", nvalue); console. writeline ("N, basic value format: {0: N3}", nvalue); console. writeline ("X, hexadecimal format: {0: x}", nvalue); console. writeline ("g, point or index: {0: g}", nvalue); console. writeline ("g, fixed point or index representation: {0: G1}", nvalue);}/** out: Number Format output formatted output 99999 C, monetization output: ¥99,999.00 D9, formatted decimal output: 000099999 E, power notation 9.999900e + 004 F, decimal Notation: 99999.000 N, basic numeric formatting: 99,999.000 X, hexadecimal notation: 1869f G, fixed Point or index: 99999 GB, fixed point or index: 1E + 05 */}

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.