[Mono-list] Console Read

Ian Norton ian.norton-badrul at thales-esecurity.com
Wed Jun 6 06:31:38 UTC 2012


On 28/05/2012 06:33, vh-bil wrote:
> I am having trouble with Console.Read and ReadLine etc. where the keys
> pressed are being output to the console without the program writing it. Is
> there an option to say the keys have been handled so they are not written to
> the console while typed?
>
> Example:
> using System;
>
> namespace test
> {
> 	class MainClass
> 	{
> 		public static void Main (string[] args)
> 		{
> 			string s = Console.ReadLine();
> 			Console.WriteLine (s + " was the text");
> 		}
> 	}
> }
>
> is outputting: (as you can see TEST is written to the console while typed)
>
> TEST
> TEST was the text
>
> Press any key to continue...

doing console.ReadKey(true) will not echo the character to the console. 
You could do this in a loop until you get all your input or get an 
Environment.NewLine

Ian




More information about the Mono-list mailing list