CSharp examples for System.Collections:IEnumerable
Are IEnumerable Equal
using System.Text; using System.Runtime.InteropServices; using System.Reflection.Emit; using System.Reflection; using System.Linq; using System.Globalization; using System.Collections.Generic; using System.Collections; using System;/* w w w. java 2 s. com*/ public class Main{ public static bool AreEqual<T>(IEnumerable<T> arr1, IEnumerable<T> arr2, bool nullAlsoIsEqual = true) where T : IComparable<T> { if (arr1 == null && arr2 == null && nullAlsoIsEqual) return true; if (arr1 == null || arr2 == null) return false; IList<T> list1 = new List<T>(arr1); IList<T> list2 = new List<T>(arr2); if (list1.Count != list2.Count) return false; for (int i = 0; i < list1.Count; i++) { if (list1[i].CompareTo(list2[i]) != 0) return false; } return true; } }