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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Sm9obg==?=

    #1

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

    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.

  • Roman Wagner

    #2
    Re: Command Line Console.WriteLi ne() ... how to refresh?

    Try this.

    using System;
    using System.Collecti ons.Generic;
    using System.Text;

    namespace Tests
    {
    class Program
    {
    static void Main(string[] args)
    {
    for (int i = 100; i 0; i--)
    {
    Console.Clear() ;
    Console.CursorL eft = 0;
    Console.Write(i );
    try
    {
    System.Threadin g.Thread.Sleep( 1000);
    }
    catch { }
    }
    }
    }
    }


    Comment

    Working...