The initial settings for a NumberFormatInfo
or DateTimeFormatInfo
are based on the invariant culture.
The following code creates a NumberFormatInfo
and change the group separator from a comma to a space, then use it to format a number to three decimal places:
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
NumberFormatInfo f = new NumberFormatInfo();
f.NumberGroupSeparator = " ";
Console.WriteLine(12345.6789.ToString("N3", f));
}
}
The output:
12 345.679
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |