Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- DrawBar(3, 0, 30);
- DrawBar(3, 1, 50, ConsoleColor.Blue);
- Console.ReadKey();
- }
- static void DrawBar(int posX, int posY, int percent, ConsoleColor color = ConsoleColor.Red)
- {
- Console.SetCursorPosition(posX, posY);
- string bar = "";
- percent /= 10;
- for (int i = 0; i < percent; i++)
- {
- bar += "#";
- }
- Console.Write("[");
- ConsoleColor prevColor = Console.BackgroundColor;
- Console.BackgroundColor = color;
- Console.Write(bar);
- Console.BackgroundColor = prevColor;
- bar = "";
- for (int i = percent; i < 11; i++)
- {
- bar += "_";
- }
- bar += "]";
- Console.Write(bar);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement