Skip to content

Instantly share code, notes, and snippets.

@autinerd
Created October 23, 2018 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autinerd/51f29e1dafa591ad8ae16ec23e4035a1 to your computer and use it in GitHub Desktop.
Save autinerd/51f29e1dafa591ad8ae16ec23e4035a1 to your computer and use it in GitHub Desktop.
Displays a console progress bar
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