How to hide user input after entered? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

How to hide user input after entered?

So basically what I'm trying to do is have the console read whatever the person says, but after they type it and hit enter, have it be removed. For example: String name; Console.WriteLine("What is your name?"); Name = Console.ReadLine(); Console.WriteLine("Hi {0}.", name); The console would look like: What is your name? Anvy Hi Anvy. What I'm trying to do is remove the second line, Anvy and have the next one be "Hi Anvy". I know there is Console.Clear() but that clears the whole console. What can I do?

16th Nov 2017, 3:54 AM
Anvy
Anvy - avatar
3 Réponses
+ 2
Maybe if you can positioned cursor at the same line at the beginning and overwrite
16th Nov 2017, 4:07 AM
Daniel
Daniel - avatar
+ 2
or if you can do some kind of input in "silent mode"
16th Nov 2017, 4:07 AM
Daniel
Daniel - avatar
+ 1
Maybe this sees a tricky way: Console.WriteLine("What is your name?"); ConsoleColor color=Console.ForegroundColor; Console.ForegroundColor=Console.BackgroundColor; string name = Console.ReadLine(); Console.ForegroundColor=color; Console.WriteLine("Hi {0}.", name);
16th Nov 2017, 6:07 AM
Petr Hatina
Petr Hatina - avatar