How to remove a character in Console
-
Hi all, Not sure if this is possible, but in a console app, is it possible to move the cursor 1 space to the left and replace the console text with a space (clearing last keystroke)? Thanks in advance
-
Hi all, Not sure if this is possible, but in a console app, is it possible to move the cursor 1 space to the left and replace the console text with a space (clearing last keystroke)? Thanks in advance
Write out a '\b' (backspace) character.
-
Write out a '\b' (backspace) character.
I tried that and I'm finding that it's not deleting, the cursor doesn't delete, it just goes back to the same pos. System.Console.WriteLine("*******************************"); System.Console.WriteLine("Press 'Q' to Quit "); System.Console.WriteLine("Press 'A' to go again"); System.Console.WriteLine("Press 'N' to start"); System.Console.WriteLine("*******************************"); do { try{ System.Console.Write("\b"); stop = validate(System.Console.ReadKey().KeyChar); //Return false if != (q,a,n) if (!stop) { System.Console.Write("\b"); } }catch(System.Exception){ stop = false; } } while (!stop);
-
I tried that and I'm finding that it's not deleting, the cursor doesn't delete, it just goes back to the same pos. System.Console.WriteLine("*******************************"); System.Console.WriteLine("Press 'Q' to Quit "); System.Console.WriteLine("Press 'A' to go again"); System.Console.WriteLine("Press 'N' to start"); System.Console.WriteLine("*******************************"); do { try{ System.Console.Write("\b"); stop = validate(System.Console.ReadKey().KeyChar); //Return false if != (q,a,n) if (!stop) { System.Console.Write("\b"); } }catch(System.Exception){ stop = false; } } while (!stop);
Write out a backspace character, then a space! The space overwites the last char. Not sure how you would actually remove it completely but, y'know. Console.Write("\b "); Should replace the last char with a space.
My current favourite word is: Waffle Cheese is still good though.
-
Hi all, Not sure if this is possible, but in a console app, is it possible to move the cursor 1 space to the left and replace the console text with a space (clearing last keystroke)? Thanks in advance
Console.Write("\b \b");
should do it. :)Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Console.Write("\b \b");
should do it. :)Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
Oh, sure, just give him the whole solution, geeze. :-D