public bool Equals(IPolygon2D other) { var poly = other as Polygon2DWithHoles; if (poly == null) { return(false); } if (!Outside.Equals(poly.Outside)) { return(false); } if (Holes.Count != poly.Holes.Count) { return(false); } var holes = Holes.ToList(); var otherHoles = poly.Holes.ToList(); for (var i = 0; i < holes.Count; i++) { if (!holes[i].Equals(otherHoles[i])) { return(false); } } return(true); }