In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you what the output format of the Console.WriteLine () function in C# is. I hope you will get something after reading this article. Let's discuss it together.
Console.WriteLine () refers to the output to the screen, which is often used in console programs, and the output is one line. The next output is displayed on the next line.
Detailed explanation of the output format of Console.WriteLine () function in C #
Format items are in the following form:
{index [, alignment] [: formatString]}
Where "index" refers to the index placeholder, which must be known.
"alignment" literally means alignment, marked with ","
": formatString" is the qualification of the output format, marked with ":".
Alignment: optional, is a signed integer indicating the preferred format field width. If the align value is less than the length of the formatted string, align is ignored and the length of the formatted string is used as the field width. If align is positive, the formatted data for the field is right-aligned; if align is negative, the formatted data for the field is left-aligned. If you need to fill it, use white space. If you specify align, you need to use a comma.
FormatString: consists of standard or custom format specifiers.
Console.WriteLine () function table
Character
Description
Exampl
Output
C
Money
String.Format ("{0:C3}", 2)
$2.000
D
Decimal system
String.Format ("{0:D3}", 2)
002
E
Scientific counting method
1.20E+001
1.20E+001
G
Routine
String.Format ("{0virtual G}", 2)
two
N
Numbers separated by semicolons
String.Format ("{0virtual N}", 250000)
250000.00
X
hexadecimal
String.Format ("{0:X000}", 12)
C
String.Format ("{0virtual 000.000}", 12.2)
012.200
Specifier
Type
Format
Output
(Passed
Double1.42)
Output
(Passed
Int-12400)
C
Currency
{0:c}
$1.42
-$12400
D
Decimal (Wholenumber)
{0:d}
System.
FormatException
-12400
E
Scientific
{0:e}
1.420000e+000
-1.240000e+004
F
Fixedpoint
{0:f}
1.42
-12400.00
G
General
{0:g}
1.42
-12400
N
Numberwithcommasforthousands
{0:n}
1.42
-12400
R
Roundtrippable
{0:r}
1.42
System.
FormatException
X
Hexadecimal
{0:x4}
System.
FormatException
Cf90
After reading this article, I believe you have a certain understanding of "what is the output format of the Console.WriteLine () function in C#". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.