same - c# rewrite console

showing percentage console application (2)

I have a console app that performs a lengthy process.

I am printing out the percent complete on a new line, for every 1% complete.

How can I make the program print out the percent complete in the same location in the console window?

Print \r to get back to the start of the line (but don't print a newline!)

For example:

using System;
using System.Threading;

class Test
    static void Main()
        for (int i=0; i <= 100; i++)
            Console.Write("\r{0}%", i);

You may use:


To set the position appropriately.

Like so:

Console.Write("Hello : ");
for(int k = 0; k <= 100; k++){
    Console.SetCursorPosition(8, 0);
    Console.Write("{0}%", k);