There’s a great site for finding extension methods, ExtensionMethod.net. I don’t believe either of these came from there, and I’ve not (yet) submitted them there, but here are a couple of extensions on IEnumerable<T> that I’ve found useful recently.
The first one is simply a method that allows you to easily iterate over a sequence and perform an action on it. This is a pretty commonly useful extension method, so much so that it’s now included in .NET 4.0 out of the box. But if you’re using an older version of the framework, this is one you can roll yourself.
If you have a collection, you can test for whether it contains an item by using the .Contains(T item) extension method. However, this only works for single instances of an item. What if you have a set of items and you need to know if that set contains any elements of a second set of items? For that, you want to use ContainsAny(), which you can use with either a params collection (specify each item inline) or with an enumerable parameter. Here are the methods:
And here are some passing unit tests that demonstrate how these are used: