C#格式化数值数据

 

C#格式化数值数据_第1张图片

 

       static void Main(string[] args)
        {
            FormatNumber();
            System.Console.ReadLine();
        }

        static void FormatNumber()
        {
            int value = 99999;
            Console.WriteLine("The value " + value + " in various formats: ");
            Console.WriteLine("c format: {0:c}",value);
            Console.WriteLine("d9 format: {0:d9}", value);
            Console.WriteLine("f3 format: {0:f3}", value);
            Console.WriteLine("n format: {0:n}", value);

            Console.WriteLine("E format: {0:E}", value);
            Console.WriteLine("e format: {0:e}", value);
            Console.WriteLine("X format: {0:X}", value);
            Console.WriteLine("x format: {0:x}", value);
        }

   

           C#格式化数值数据_第2张图片

 

 

你可能感兴趣的:(C#)