hi,yoyo_houda
I think eradicator's answer is a good solution for implementing the function you described above.
And regarding the question "why on pressing enter it goes out of the program ?"I think you can get answer from the following remarks about the System.Console.Read function.
The Read method blocks its return while you type input characters; it terminates when you press the Enter key. Pressing Enter appends a platform-dependent line termination sequence to your input (for example, Windows appends a carriage return-linefeed sequence). Subsequent calls to the Read method retrieve your input one character at a time. After the final character is retrieved, Read blocks its return again and the cycle repeats.
for detail information,you canvisit: http://msdn2.microsoft.com/en-us/library/system.console.read.aspx