2007.1.1 string.Format

String.Format举例(C#) stringstr1 =string.Format("{0:N1}",56789);

                //result: 56,789.0 stringstr2 =string.Format("{0:N2}",56789);

                //result: 56,789.00 stringstr3 =string.Format("{0:N3}",56789);

                //result: 56,789.000 stringstr8 =string.Format("{0:F1}",56789);

                //result: 56789.0 stringstr9 =string.Format("{0:F2}",56789);

                //result: 56789.00 stringstr11 =(56789 / 100.0).ToString("#.##");

            //result: 567.89 stringstr12 =(56789 / 100).ToString("#.##");

              //result: 567C 或 c 货币 Console.Write("{0:C}", 2.5);

   //$2.50 Console.Write("{0:C}", -2.5);

 //($2.50)D 或 d 十进制数 Console.Write("{0:D5}", 25);

   //00025E 或 e 科学型 Console.Write("{0:E}", 250000);

   //2.500000E+005F 或 f 固定点 Console.Write("{0:F2}", 25);

   //25.00 Console.Write("{0:F0}", 25);

   //25G 或 g 常规 Console.Write("{0:G}", 2.5);

   //2.5N 或 n 数字 Console.Write("{0:N}", 2500000);

   //2,500,000.00X 或 x 十六进制 Console.Write("{0:X}", 250);

   //FA Console.Write("{0:X}", 0xffff);

   //FFFF

posted on 2016-10-15 18:39  mol1995  阅读(141)  评论(0编辑  收藏  举报

导航