How can I use (.) Instead of (,) as grouping separator when displaying a number using String.Format?
I want to change change (,) to (.) When using String.Format in C #
String.Format ("{0: 0,0}", 1000) โ 1000
But I want: 1.000
Can anyone help me?
+3
Nguyแป
n Huy
source
to share
3 answers
You can accomplish this with
ToString(new CultureInfo("nl-NL"))
Basically any CultureInfo that matches your description.
Read it here at CultureInfo - MSDN
+2
Pmleader
source
to share
You can do it like this:
NumberFormatInfo newNumberFormat= (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
newNumberFormat.NumberGroupSeparator = ".";
string.Format(newNumberFormat,"{0:#,#}",1000);
0
Reniuz
source
to share
You can use this with your var number:
NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NumberDecimalSeparator = ".";
string myNumbreString = myNumber.ToString("0.00", nfi);
0
mggSoft
source
to share