public static bool DataStructureEquals(IDataStructure a, IDataStructure b) { if (a.GetType() != b.GetType()) { return(false); } if (a.Name != b.Name) { return(false); } var aCount = a.DataPoints.Count(); if (aCount != b.DataPoints.Count()) { return(false); } var enA = a.DataPoints.GetEnumerator(); var enB = b.DataPoints.GetEnumerator(); try { for (var i = 0; i < aCount; i++) { if (DataPointComparator(enA.Current, enB.Current)) { return(false); } } } finally { enA.Dispose(); enB.Dispose(); } return(true); }