C# 3.0 New Feature for the Week #4: Extension Methods (and a PowerCollections Bonus!)

Saturday, December 1, 2007

Consider the following. You need to sort an IEnumerable<T>. By default, Sort is only available for T (arrays) and List<T> (generic list). So you write something like this (probably not the most efficient implementation, this is just an example): namespace Utils { public static class CollectionUtils { public static IEnumerable<T> Sort<T>(IEnumerable<T> collection) { List<T> toSort = new List<T>(collection); ...
no comments

Upgrading to .NET 2.0? PowerCollections to your Aid.

Saturday, September 1, 2007

The .NET 2.0 framework has been here a while, but if you're like my team, you're still using a lot of code that you wrote back at the .NET 1.1 days. It's likely that many of these methods are using non-generic collections. This poses an annoying issue. Check out this method: public IList GetAllUsers(IList userCodes) { IList list = new ArrayList(); //Add the users here... //... return list; ...
no comments