0

I have played at writing a C# program. It is to work out surface areas.

My problem is that the int is being displayed as I believe Unicode? eg 3 is displayed as 51

Here is a snippet of the code.

double area;
double width;

Console.WriteLine("Please input width or Height of one side of cube");
width = Console.Read();
Console.WriteLine(width); // to check input
area = (width * width) * 6;

Console.WriteLine(area); 

Am I using the wrong commands? or can it be reverted to the double the int is passed to?

  • what are you inputting? –  Aug 18 '17 at 10:23
  • i am inputting an int – Computer Science Aug 18 '17 at 10:26
  • Thanks The answer was width = double.Parse(Console.ReadLine()); instead of width = Console.Read(); Im still a little confused as I felt .Read would output an int that would be converted to double. I believe i am now taking in a string and converting to double? – Computer Science Aug 18 '17 at 10:57
  • I meant what numbers but yeah, Console.ReadLine() will retun a string https://msdn.microsoft.com/en-us/library/system.console.readline(v=vs.110).aspx –  Aug 18 '17 at 12:54

0 Answers0