Thousands of delimiters in .Net / F #

What is the recommended way to print a whole with a thousands separator? The best I've come up with is

let thousands(x:int64) = String.Format("{0:0,0}", x)

Which works in most cases, but prints zero as 00.

+5
source share
3 answers
let thousands(x:int64) = String.Format("{0:#,0}", x)
0
source

The formatting tone for the decimal place in .NET is ".". regardless of the culture that the assembly uses, and "," for the thousandth separator. However, different cultures (e.g. France) use "," for decimals, so this may be a problem to consider.

Here are some examples (C #):

C
£N
£#,#

double x = 67867987.88666;  
Console.WriteLine("{0:C}",x);  
Console.WriteLine("£{0:N}", x);  
Console.WriteLine("£{0:#,#.###}", x);  

Output:  
£67,867,987.89  
£67,867,987.89  
£67,867,987.887

More details here .

+5
source
let thousands(x:int64) = String.Format("{0:#,###}", x)
0

All Articles