格式化数值数据

Posted on 2019-02-01 11:15  努力成长静待花开  阅读(146)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  (给定的占位符以冒号为标记 将这些字符作为后缀)

  

实现代码:

        static void Main(string[] args)
        {
            Console.WriteLine("The Value 99999 in various formats:");
            Console.WriteLine("C Format: {0:C}",99999);
            Console.WriteLine("D9 Format: {0:D9}",99999);
            Console.WriteLine("E Format: {0:E}", 99999);
            Console.WriteLine("F9 Format: {0:F9}",99999);
            Console.WriteLine("N Format: {0:N}",99999);
            Console.WriteLine("X Format: {0:X}",99999);
            Console.WriteLine("x Format: {0:x}",99999);
        }