如何在 C# 中同时将 ,(逗号)和 .(点)输入到 TextBox 中

How to input ,(comma) and .(dot) into the TextBox at the same time in c#

我想知道如何在文本框中同时输入,.

例如)

1,234.22,
12,554.00,
555,448,999.513

非常感谢

使用String.Format来做到这一点,例如:

// Output will be 555,448,999.513
string s = string.Format(new CultureInfo("en-US"), "{0:n3}", 555448999.513);

String.Format 显示 , 和 的另一种方式。没有 CultureInfo

decimal v = 123018401398.313m;
Console.WriteLine(string.Format("{0:0,000.00}", v));
// Output is 123,018,401,398.31

请注意,您需要指定小数位数。此示例仅显示 2.