Contango Contango -4 years ago 107
C# Question

Is there a way to delete a character that has just been written using Console.WriteLine?

Is there any way to delete the last character from the console, i.e.

Console.WriteLine("List: apple,pear,");
// Somehow delete the last ',' character from the console.
// Now the console contains "List: apple,pear."

Sure, I could create a string first then print that to the console, but I'm just curious to see if I can delete characters directly from the console.

Answer Source

"\b" is ASCII backspace. Print it to back up one char.


outputs "AbDef";

As pointed out by Contango and Sammi, there are times where overwriting with a space is required: Console.Write("\b \b");

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download