Over write text in a window's console application

Today I had a need to display a counter on a Console application and I was trying to think of a way to over write the existing number with the new number in the console window, using C#.  So after thinking about it for a minute it came to me, just write backspace characters.  Well anyways just incase anyone would ever need this here is a simple example: 

for(int i = 0; i < 1000; i++)
{
  if(i > 0)
    Console.WriteLine(new string('\b', (i-1).ToString().Length));

  Console.WriteLine(i.ToString());
}

5 Comments

Comments have been disabled for this content.