格式化数值数据的显示

        static void Main(string[] args)
        {
            Console.WriteLine("*********");

            FromatNumbericalData();
            DisplayMessage();

            Console.ReadLine();
        }

        private static void DisplayMessage()
        {
            string userMessage = string.Format("1000 in hex is {0:x}", 100000);
            System.Windows.Forms.MessageBox.Show(userMessage);
        }

 

        static void Main(string[] args)
        {
            Console.WriteLine("*********");

            FromatNumbericalData();

            Console.ReadLine();
        }

        private static void FromatNumbericalData()
        {
            Console.WriteLine("the value 99999 in various formats:");
            Console.WriteLine("c format:{0:c}", 99999);
            Console.WriteLine("d9 fromat:{0:d9}", 99999);
            Console.WriteLine("f3 format:{0:f3}", 99999);
            Console.WriteLine("n format:{0:n}", 99999);
            //十六进制数的大小写形式决定了字母是大写还是小写
            Console.WriteLine("E format:{0:E}", 99999);
            Console.WriteLine("e format:{0:e}", 99999);
            Console.WriteLine("X format:{0:X}", 99999);
            Console.WriteLine("x format:{0:x}", 99999);

        }

 

posted @ 2013-04-27 09:52  zengxw  阅读(110)  评论(0)    收藏  举报