格式化数值数据

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace ConsoleApplication12
 8 {
 9     class Program
10     {
11         //使用一些格式化标记
12         static void Main(string[] args)
13         {
14             Console.WriteLine("The value 99999 in various formats:");
15             Console.WriteLine("c format: {0:c}",99999);
16             Console.WriteLine("d9 format: {0:d9}",99999);
17             Console.WriteLine("f3 format: {0:f3}",99999);
18             Console.WriteLine("n format: {0:n}",99999);
19 
20             //注意.十六进制数的大小写形式决定了字母是大写还是小写
21             Console.WriteLine("E format: {0:E}",99999);
22             Console.WriteLine("e format: {0:e}",99999);
23             Console.WriteLine("X format: {0:X}",99999);
24             Console.WriteLine("x format: {0:x}",99999);
25             Console.ReadKey();
26         }
27     }
28 }

效果显示:

posted @ 2015-12-25 10:03  翻滚吧炒鸡蛋  阅读(82)  评论(0)    收藏  举报