7
Answers

Read()

Maha

Maha

11y
984
1
This program is given in the following website:
http://www.dotnetperls.com/console-read

According to code while ((result = Console.Read()) != 0) program must end when input is 0, but it is not ending. Please explain the reason. Problem is highlighted.

using System;

class Program
{
static void Main()
{
int result;

while ((result = Console.Read()) != 0)
{
Console.WriteLine("{0} = {1}", result, (char)result);
}

Console.ReadKey();
}
}

Answers (7)