ReadLine and WriteLine

A

alberto

In this code for a console application:

int n;

n = Console.Read();

Console.WriteLine(n);

Console.ReadLine();



I need write the last sentence (Console.ReadLine()) twice to the program
make a pause. Can somebody tell me why? Thank you
 
W

wackyphill

Console.Read() only picks up the 1st char. SO if you enter like "h"
enter it gets the h but the newline is still in the buffer and gets
picked up by your next readline.

Then you needed an aditional readline to actually wait for you to press
enter again and pause.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top