Format - Numeric

1. 一些常用格式,参考链接:http://msdn.microsoft.com/en-us/library/0c899ak8(v=vs.110).aspx

            int value = -1234;
            Console.WriteLine(value.ToString("D8"));

            double doubleNumber = 12345.678;
            Console.WriteLine(doubleNumber.ToString("E",CultureInfo.InvariantCulture)); //1.234568E+004

            int integerNumber = 1234567;
            Console.WriteLine(integerNumber.ToString("F")); //1234567.00

            int zeroSpecifierInteger = 1234;
            Console.WriteLine(zeroSpecifierInteger.ToString("00000")); //01234

            double zeroSpecifierDouble = 12.345;
            Console.WriteLine(zeroSpecifierDouble.ToString("00.00"));   //12.35
            Console.WriteLine(zeroSpecifierDouble.ToString("000.00")); //012.35

            double zeroSpecifierWithComma = 1234567890.890;
            Console.WriteLine(zeroSpecifierWithComma.ToString("0,0.00",CultureInfo.InvariantCulture)); //1,234,567,890.89

            Console.Read();

 

2. 

posted @ 2014-04-18 10:15  Jacky Ge  阅读(346)  评论(0编辑  收藏  举报