Created
October 23, 2018 11:36
-
-
Save autinerd/51f29e1dafa591ad8ae16ec23e4035a1 to your computer and use it in GitHub Desktop.
Displays a console progress bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void RenderProgressbar(int percentage) { | |
int width = Console.WindowWidth - 3 - 3 - 2; | |
int number = (int)(((double)percentage / 100) * width); | |
string pattern = ""; | |
for (int j = 0; j < number; j++) | |
{ | |
pattern += "#"; | |
} | |
for (int j = 0; j < width - number; j++) | |
{ | |
pattern += " "; | |
} | |
Console.Write(string.Format("{0,3}", i) + "% [" + pattern + "]" + ((i != 100) ? "\r" : "\n")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment