[C #] Console progress bar example,
See the [vb.net] Console progress bar example
It's fun to translate it into C.
Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; using System. threading; namespace ConsoleProcessBar {class Program {static void Main (string [] args) {Boolean isBreak = false; ConsoleColor colorBack = Console. backgroundColor; ConsoleColor colorFore = Console. foregroundColor; // (0, 0) (Left, Top) Console on the first line. writeLine ("************ TE Mason *** * ********* "); Console. backgroundColor = ConsoleColor. darkCyan; for (int I = 0; I <Console. required wwidth-3; I ++) {// (0, 1) Second Console. write ("");} // () Second line Console. writeLine (""); Console. backgroundColor = colorBack; // '() The third Console. writeLine ("0%"); // '() The fourth Console. writeLine ("<press Enter to stop>"); for (int I = 0; I <= 100; I ++) {if (Console. keyAvailable & Console. readKey (true ). key = ConsoleKey. enter) {isBreak = true; break;} Console. backgroundColor = ConsoleColor. yellow; // '/returns the complete quotient, including the remainder. SetCursorPosition is automatically rounded to the Console. setCursorPosition (I * (Console. required wwidth-2)/100, 1); // 'msgbox (I * (Console. required wwidth-2)/100); // 'msgbox (Console. cursorLeft); // 'msgbox (Console. cursorSize); Console. write (""); Console. backgroundColor = colorBack; Console. foregroundColor = Cons OleColor. green; Console. setCursorPosition (0, 2); Console. write ("{0} %", I); Console. foregroundColor = colorFore; Thread. sleep (500);} Console. setCursorPosition (0, 3); Console. write (isBreak? "Stop !!! ":" Complete "); Console. WriteLine (" "); Console. ReadKey (); Console. ReadKey (true );}}}