Console applications are not Graphics oriented – they are character based, and your outputs are limited to the characters you can print to the screen – there are no DrawLine or DrawElipse functions.
We can print the circle with “*”. Dont forget ,you can print circle by the “*” characters but with not goodness
You also like this: Draw a rectangle in c# console
Screenshot:
Here are the codes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
class Program { static void Main(string[] args) { double radius; double thickness = 0.4; ConsoleColor BorderColor = ConsoleColor.Yellow; Console.ForegroundColor = BorderColor; char symbol = '*'; do { Console.Write("Enter radius:::: "); if (!double.TryParse(Console.ReadLine(), out radius) || radius <= 0) { Console.WriteLine("radius have to be positive number"); } } while (radius <= 0); Console.WriteLine(); double rIn =radius- thickness, rOut = radius + thickness; for (double y = radius; y >= -radius; --y) { for (double x = -radius; x < rOut; x += 0.5) { double value = x * x + y * y; if (value >= rIn * rIn && value <= rOut * rOut) { Console.Write(symbol); } else { Console.Write(" "); } } Console.WriteLine(); } Console.ReadKey(); } } |
can You explain the program?