static void Main(string[] args) { Collection2 col1 = new Collection2(); col1.Add(3); col1.Add(4); col1.Add(6); col1.Add(7); col1.Add(12); col1.Add(8); Collection2 col2 = new Collection2(); col2.Add(3); col2.Add(4); col2.Add(6); col2.Add(7); col2.Add(12); col2.Add(8); int[] arr = col1.ToArray(); for (int i = 0; i < arr.Length; i++) { Console.Write(arr[i].ToString() + ", "); } Console.WriteLine(); Console.WriteLine(col1.Equals(col2)); Console.WriteLine(col1.Get(0)); Console.WriteLine("Size of Collection2:" + col1.Size()); Console.WriteLine("Index of number 6:" + col1.IndexOf(6)); col1.Remove(5); Console.WriteLine("After removing the 3th member"); col1.PrintCollection2(); col1.Insert(200, 5); Console.WriteLine("After inserting 200 in index 3:"); col1.PrintCollection2(); Console.WriteLine(); Console.WriteLine(); Console.ReadKey(); }
public bool Equals(Collection2 other) { if (other == null) { return(false); } if (other == this) { return(true); } Link current = this.anchor; Link currentOther = other.anchor; while (current.next != null && currentOther.next != null) { current = current.next; currentOther = currentOther.next; if (current.value != currentOther.value) { return(false); } } return(current.next == currentOther.next); }