本文介绍了使用十进制格式设置双千位分隔符,但不包含尾随零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一个格式来与 string.Format 一起使用,它将打印下面的内容:
double d = 123456.123456D;
double d2 = 123456D;
123,456.123456
123,456
{0:N6}结果
123,456.123456
123,456.000000
{0:0。######}导致
123456.123456
123456
{0:#。0}导致
123,456
123,456
我不能锻炼格式,将让我到我所需要的。我需要定义自己的格式提供程序吗?
你很近。使用这种格式: {0:#,0。######}
I am looking for a format to use with string.Format that would print the following
double d = 123456.123456D;
double d2 = 123456D;
like
123,456.123456
123,456
{0:N6} results in
123,456.123456
123,456.000000
{0:0.######} results in
123456.123456
123456
{0:#.0} results in
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.######}
这篇关于使用十进制格式设置双千位分隔符,但不包含尾随零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!