Search code examples
c#number-formatting

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


I wanna know how to input , and . into the TextBox at the same time

ex)

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

thank you very much


Solution

  • Use String.Format to do that, example:

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