C#FormatException错误

时间:2015-09-15 00:34:49

标签: c#

以下是错误后面的代码..编译正常,但在运行程序时会在代码下面显示错误。

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



class GlazerCalc
{

    static void Main()
    {
        double width, height, woodLength, glassArea;
        string widthString, heightString;
        // Console.ReadLine(); asks the user to input a value, and is placed in the widthString variable

        widthString = Console.ReadLine();
        width = double.Parse(widthString);

        heightString = Console.ReadLine();
        height = double.Parse(heightString);

        woodLength = 2 * (width + height) * 3.25;
        glassArea = 2 * (width * height);

        Console.WriteLine("The length of the wood is " +
        woodLength + " feet");

        Console.WriteLine("The area of the glass is " +
        glassArea + " square metres");

    }
}
  

未处理的异常:System.FormatException:输入字符串不在   格式正确。在System.Number.ParseDouble(字符串值,   NumberStyles选项,NumberFormatInfo numfmt)at   System.Double.Parse(String s)在GlazerCalc.Main()中   C:\ VisualStudio \ Learning \ Learning \ Program.cs:第19行

     

调试错误:类型为“System.FormatException”的未处理异常   发生在mscorlib.dll中附加信息:输入字符串不是   格式正确。

0 个答案:

没有答案