简体   繁体   English

如何把千分离器“点”

[英]How to put thousand seperator “point”

Since 3 days I'm searching this but I can't find something useful. 从3天开始,我正在搜索这个,但我找不到有用的东西。 I just want to format number like 12345 to 12.345 but all examples with comma, I want to use thousand seperator with "dot" 我只想格式化数字,如1234512.345但是所有的例子都用逗号,我想用千分之一的“点”分隔符

I checked this example also Custom Numeric Formatting but it's working on my server but not working on customer server? 我检查了这个例子也是自定义数字格式,但它在我的服务器上运行但不在客户服务器上工作? Always showing with comma? 总是用逗号显示?

It all depends on the code used in conjunction with the regional settings of your machine. 这一切都取决于与您的机器的区域设置一起使用的代码。

If you use this code, it will use the default regional settings of your machine (if you didn't deviate in your program): 如果您使用此代码,它将使用您机器的默认区域设置(如果您没有偏离您的程序):

string s = 12345.ToString("N0");

If you want to use a specific culture (one that had a . as thousand separator), you can supply that to the method: 如果您想使用特定的文化(具有.千分隔符的文化),您可以将其提供给该方法:

string s = 12345.ToString("N0", new System.Globalization.CultureInfo("nl-nl"));
        NumberFormatInfo nf = new CultureInfo(CultureInfo.CurrentCulture.Name).NumberFormat;
        Console.WriteLine(12345.ToString("N0", nf));
        nf.NumberGroupSeparator = ".";
        Console.WriteLine(12345.ToString("N0", nf));
        nf.NumberGroupSeparator = "z";
        Console.WriteLine(12345.ToString("N0", nf));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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