Command Line Console.WriteLine() ... how to refresh?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am writing a command line app, I have a question that's driving me crazy:
Is it possible to update a printed line without having to write a new line,
so that, for example, I could achieve the spinning effect: | / - \ | or do a
countdown 30 29 28 ... without having to write a new line every time I update.

Any help would be greatly appreciated

Thanks!

JT.
 
Try this.

using System;
using System.Collections.Generic;
using System.Text;

namespace Tests
{
class Program
{
static void Main(string[] args)
{
for (int i = 100; i > 0; i--)
{
Console.Clear();
Console.CursorLeft = 0;
Console.Write(i);
try
{
System.Threading.Thread.Sleep(1000);
}
catch { }
}
}
}
}
 
Back
Top