如何放置千位分隔符 "point"

How to put thousand seperator "point"

3 天以来,我一直在搜索这个,但找不到有用的东西。我只想将 12345 之类的数字格式化为 12.345 但所有示例都带有逗号,我想将千位分隔符与 "dot"

一起使用

我也检查了这个例子 Custom Numeric Formatting 但它在我的服务器上工作但在客户服务器上不工作?总是以逗号显示?

这完全取决于与您机器的区域设置结合使用的代码。

如果您使用此代码,它将使用您机器的默认区域设置(如果您在程序中没有偏离):

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

如果您想使用特定区域性(具有 . 作为千位分隔符的区域性),您可以将其提供给方法:

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));