harish reddy

harish reddy

  • 1.9k
  • 162
  • 22.6k

Console Readline

Jun 3 2017 2:02 AM
Console.WriteLine("Input the length and breadth");
int a = 10;
Console.WriteLine("Lenght of the rectangle is" + " " + a );
Console.Writeline("Now enter the \"breadth\" of rectangle");
Console.ReadLine();
int b = int.Parse(Console.ReadLine());
int Perimeter = 4*(a*b);
int Area = a*b;
Console.WriteLine("The perimeter of rectangle is" + " "+ Perimeter);
Console.WriteLine("The area of rectangle is" + " " + Area);
First question :
In the above program if i comment out console.readline(); , then i am getting the output.
But, if i dont comment out console.readline();, then i am getting an exception error. Why?
second Question:
When the fourth line of code is executed i.e Console.Writeline("Now enter the \"breadth\" of rectangle"); i am getting a cursor mark to input the value from user. But the same cursor mark is not appearing where there are other console.writeline . Why?
Third question:
I have confusion when we use Console.readline(); What does this do?

Answers (7)