C#NumberFormatInfo类

 1 class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             //retrieve current culture info by cloning it so that
 6             //we can manipulate its NumberFormat member
 7             CultureInfo ci = Thread.CurrentThread.CurrentCulture.Clone() as CultureInfo;
 8             NumberFormatInfo nfi = ci.NumberFormat;
 9 
10             //set "123456" to "123|456*"
11             nfi.CurrencyPositivePattern = 1;
12             nfi.CurrencyGroupSeparator = "|";
13             nfi.CurrencySymbol = "*";
14             nfi.CurrencyDecimalDigits = 0;
15             //reset the NumberFormat
16             ci.NumberFormat = nfi;
17             //set the thread culture to our modified CultureInfo
18             Thread.CurrentThread.CurrentCulture = ci;
19             Console.WriteLine(123456.ToString("C"));
20             //"C" indicate use Currency format
21         }
22     }

 

 and the interval :every three digits.

 

 

posted on 2013-12-13 23:41  jec  阅读(830)  评论(0编辑  收藏  举报

导航