Polygon myPolygon = new Polygon(); myPolygon.AddPoint(0, 0); myPolygon.AddPoint(0, 5); myPolygon.AddPoint(5, 5); myPolygon.AddPoint(5, 0);
ListIn this example, we create a list of PointF objects and add 4 points to create a square. We then create a new polygon object and pass in the list of points. Finally, we add a new point at (2, 2) to the polygon. Package/Library: System.Drawing.pointsList = new List (); //using System.Drawing; pointsList.Add(new PointF(0, 0)); pointsList.Add(new PointF(0, 5)); pointsList.Add(new PointF(5, 5)); pointsList.Add(new PointF(5, 0)); Polygon myPolygon = new Polygon(pointsList); myPolygon.AddPoint(2, 2);