![]() |
How to clear console buffers
Hi
i have to take input from user in console using Console.Read() and Console.Readline() functions but whenever i use Console.Readline() before Console.Read() , the Console.Read() funtion does not execute plz help eg :
using System; |
First of all, Console.Read is used for reading single characters, not tokens. Read the int in using int x = int.Parse(Console.ReadLine()); .
The reason the second Read didn't seem to be executing was that you were entering one on each line: when you typed an integer, the first function read the character... then the next read the rest of the line. The string you typed was read partially by the third, and then dropped when your program finished. |
Quote:
i have also tried to do this :
char x=(char)Console.Read(); |
Try typing:
:
x Something |
| All times are GMT -5. The time now is 2:13 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC