Or how to display a progress indicator in a console app:
// Avoid a blinking cursor. Console.CursorVisible = false; Console.WriteLine("Downloading..."); for (int i = 0; i <= 100; i++) { // Overwrite the output on the current line. Console.CursorLeft = 0; Console.Write($"Progress: {i.ToString(),3}%"); await Task.Delay(50); } // Terminate the progress line. Console.WriteLine(); Console.WriteLine("Download complete.");
Output:
Downloading... Progress: 100% Download complete.
That's all!