I have the following code:
using System;
namespace MyApp {
class KeyBoardInputTest {
static void Main() {
Console.Write("Enter a character >\t");
char ch = (char)Console.Read();
Console.WriteLine("");
if(Char.IsLetter(ch)) {
if(Char.IsUpper(ch))
Console.WriteLine("You have entered an upper case character");
else
Console.WriteLine("You have entered a lower case character");
}
else if(Char.IsNumber(ch))
Console.WriteLine("You have entered a numeric character");
else
Console.WriteLine("You have entered a non alpha-numeric character");
Console.Read();
}
}
}
After taking an input such as a it is straightaway showing result without waiting for me to press Enter
Using Console.ReadLine()
gives the error -
error CS0030: Cannot convert type 'string' to 'char'
Using Console.ReadKey()
gives the error -
error CS0030: Cannot convert type 'System.ConsoleKeyInfo' to 'char'