简体   繁体   中英

Is there a format with fixed number of digits in c#?

I mean if I set to 6

if I have 123, I would get 123.000
if I have 123.45, I would get 123.450
if I have 123456 I would 123456
if I have 1234567 I would get 1234567

In Math there is a name for this though I don't remember.

I can't see it here ? http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

My question is for C# NOT JAVA and about using STANDARD in this language if it exists not custom algorithm since some people thumbed down : they seem to reinvent the wheel.

The "#" Custom Specifier

Or just do it manually

Hope it helps, but I still dont get if you just want always 3 decimals or what?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM