469,140 Members | 1,355 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,140 developers. It's quick & easy.

Clear Buffer before my Second Console.Read()

Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a line
feed).

How do I clear out that line feed before I call Console.Read() again?
Nov 16 '05 #1
3 12023
Steve,

Can you show the code where this is happening? Console.Read shouldn't
be feeding you the line character (I think).

If anything, why not use ReadLine?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a line
feed).

How do I clear out that line feed before I call Console.Read() again?

Nov 16 '05 #2
char letter = (char)Console.Read();

The first time through it is fine. The second time I can see in the
debbuger the a line feed is already in there.

I'm using Read instead of ReadLine becuase I just want a single char instead
of a string, and it seems like it would be simplier to do it this way.

Of course depending on what it takes to get around this issue I might change
my ind.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uu**************@TK2MSFTNGP15.phx.gbl...
Steve,

Can you show the code where this is happening? Console.Read shouldn't
be feeding you the line character (I think).

If anything, why not use ReadLine?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a
line feed).

How do I clear out that line feed before I call Console.Read() again?


Nov 16 '05 #3
Steve,

You probably should do a readline. The reason for this is that when
dealing with console input, the buffer is not going to be filled until a
line is entered. Because of this, it's easier to just read the line and
process the string than it is to read character by character.

In .NET 2.0 however, there are ways of detecting when there is a
keypress, which might be of use to you.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:u$**************@TK2MSFTNGP14.phx.gbl...
char letter = (char)Console.Read();

The first time through it is fine. The second time I can see in the
debbuger the a line feed is already in there.

I'm using Read instead of ReadLine becuase I just want a single char
instead of a string, and it seems like it would be simplier to do it this
way.

Of course depending on what it takes to get around this issue I might
change my ind.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uu**************@TK2MSFTNGP15.phx.gbl...
Steve,

Can you show the code where this is happening? Console.Read shouldn't
be feeding you the line character (I think).

If anything, why not use ReadLine?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Okay I call Console.Read() twice. However when I come up on my second
Console.Read() ASCII character 10 is already on the console (that's a
line feed).

How do I clear out that line feed before I call Console.Read() again?



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
3 posts views Thread by voidstar | last post: by
5 posts views Thread by nx-2000 | last post: by
1 post views Thread by AD | last post: by
1 post views Thread by noel.phillips | last post: by
Osoascam
2 posts views Thread by Osoascam | last post: by
331 posts views Thread by Xah Lee | last post: by
7 posts views Thread by Just Me | last post: by
9 posts views Thread by pbd22 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.