DrowningGeodude
New member
- Joined
- Feb 11, 2022
- Messages
- 4
- Programming Experience
- Beginner
Hi, I am a beginner in C# and I am currently learning this program from an online PDF book.
Within the book there is a code example and the author stated that it should work if I put it in a C# compiler.
However, when I copy and paste the code into an online compiler I got this error message:
This is the code from the book:
Within the book there is a code example and the author stated that it should work if I put it in a C# compiler.
However, when I copy and paste the code into an online compiler I got this error message:
C#:
Unhandled Exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: s
at System.Double.Parse (System.String s) [0x00006] in <12b418a7818c4ca0893feeaaf67f1e7f>:0
at GlazerCalc.Main () [0x00007] in <31db6a95be144b39a4590ec15e205963>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
Parameter name: s
at System.Double.Parse (System.String s) [0x00006] in <12b418a7818c4ca0893feeaaf67f1e7f>:0
at GlazerCalc.Main () [0x00007] in <31db6a95be144b39a4590ec15e205963>:0
C#:
using System;
class GlazerCalc
{
static void Main()
{
double width, height, woodLength, glassArea;
string widthString, heightString;
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" ) ;
}
}
Last edited by a moderator: