Tuesday 31 December 2019

c# - .NET String.Format() to add commas in thousands place for a number



I want to add a comma in the thousands place for a number. String.Format()?


Answer



String.Format("{0:n}", 1234);  // Output: 1,234.00
String.Format("{0:n0}", 9876); // No digits after the decimal point. Output: 9,876

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...