CSharp examples for System.Collections.Generic:IEnumerable
Determines if the two given sequences contain the same items, not counting duplicates.
using System.Linq; using System.Collections.Generic; using System;/*from www .j av a2 s .c o m*/ public class Main{ ///<summary>Determines if the two given sequences contain the same items, not counting duplicates.</summary> public static bool HasSameSetOfItemsAs<T>(this IEnumerable<T> sequence, IEnumerable<T> other) { var r1 = new HashSet<T>(other); var r2 = new HashSet<T>(sequence); return r1.Count == r2.Count && r2.All(r1.Contains); } }