[英]Format double - thousands separator with decimal but no trailing zeros
I am looking for a format to use with string.Format that would print the following 我正在寻找一种格式与string.Format一起使用,将打印以下内容
double d = 123456.123456D;
double d2 = 123456D;
like 喜欢
123,456.123456
123,456
{0:N6} results in {0:N6}导致
123,456.123456
123,456.000000
{0:0.######} results in {0:0。######}导致
123456.123456
123456
{0:#.0} results in {0:#。0}导致
123,456
123,456
I cannot workout a format that will get me to what I need. 我无法锻炼能够满足我需要的格式。 Will I need to define my own format provider ? 我需要定义自己的格式提供程序吗?
You're close. 你很亲密 Use this format: 使用以下格式:
{0:#,0.######}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.