Draw an ellipse in C#



To draw an ellipse, use the drawEllipse() method in C# that belong to the Graphics object. It has a pen object as well as a rectangle object.

You need windows form to draw shapes in C#.

Set graphics object.

 Graphics g = this.CreateGraphics(); 

Now, the pen object.

 Pen p = new Pen(new SolidBrush(Color.Red), 15); 

The following is the rectangle object.

 Rectangle r = new Rectangle(120, 60, 180, 180); 

Now use the drawEllipse() method with the graphics object and add both the objects in it to draw an ellipse.

 s.DrawEllipse(p, r); 
Updated on: 2019-07-30T22:30:23+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements