0

How Can I Accept an input Character?

19th Jun 2017, 9:43 AM
Herlem A. Martinez
Herlem A. Martinez - avatar
5 Respuestas
+ 1
All inputs strings so you'll need to access the character value like this: string x = Console.readline(); char y = x[0];
19th Jun 2017, 10:04 AM
Limitless
Limitless - avatar
+ 1
I tried to input multiple characters and I didn't received an error :) I guess the difference in ReadLine() and Read() is demonstrated in this problem.
20th Jun 2017, 1:38 PM
Herlem A. Martinez
Herlem A. Martinez - avatar
+ 1
i found a solution sir, say for example: char let; let = (char) Console.Read(); I have used this code for my Customized Pyramid Program :)
20th Jun 2017, 1:38 PM
Herlem A. Martinez
Herlem A. Martinez - avatar
0
Hmm try typing more than one character and tell me if you get an error
19th Jun 2017, 1:27 PM
Limitless
Limitless - avatar
0
If you specifically want a character as input then try ReadKey(). It only takes one key press as it's input, dont even need to press enter after pressing the key haha.
30th Jun 2017, 9:59 AM
Pierre Gravelle
Pierre Gravelle - avatar