Tim Van Wassenhove

Passionate geek, interested in Technology. Proud father of two

06 Aug 2008

Presenting EnumerableHelper

I noticed (eg: here) that i’m not the only one that has experienced some annoyances when working with generics. Here are a couple of methods that i find extremely helpful when i’m working with IEnumerable:

IEnumerable<tbase> Convert<tderived, TBase>(IEnumerable<tderived> enumerable) where TDerived : TBase;
IEnumerable<t> Convert<t>(IEnumerable enumerable);
bool HaveSameElements<t>(IEnumerable<t> enumerable1, IEnumerable<t> enumerable2, Func<bool, T, T> areEqual);
bool HaveSameElements(IEnumerable enumerable1, IEnumerable enumerable2, Func<bool, object, object> areEqual);
bool HaveSameElements(IEnumerable enumerable1, IEnumerable enumerable2);

You can download the actual implementation of this Be.Timvw.Framework.Collections.Generic.EnumerableHelper class in BeTimvwFramework.