Convert 输入字符串的格式不正确

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            double d = 0;
            try
            {
                d = Convert.ToDouble(str);
                Console.WriteLine("{0}", d);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("1,{0}", ex.Message);
            }

            str = null;
            try
            {
                d = Convert.ToDouble(str);
                Console.WriteLine("2,{0}", d);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("{0}", ex.Message);
            }
//1,输入字符串的格式不正确。
//2,0
//请按任意键继续. . .
        }
    }
}

 

posted @ 2017-03-14 10:44  sky20080101  阅读(412)  评论(0编辑  收藏  举报