As I was updating Power Collections to use Beta 2, I found an somewhat unfortunate change that had been made since Beta 1. Arrays in .NET have always implemented the IList interface, so you have always been able to convert an int[], say, to an IList, and use that IList to read and write the elements of the array. This is very useful, because you can write algorithms that take an IList, and use that IList without knowing whether they are using an array of object, an array of string, an array of ints, an ArrayList, or any other kind of object that implements IList.

With the advent of generics, there is now a generic IList<T> interface, which can be specialized to describe lists of any specific type. For example, IList<int> allows reading and writing a list-like object that can only contains ints. Now, it makes total sense that int[] should implement IList<int>, string[] should implement IList<string>, etc. And, in fact, this is the case in both Beta 1 and in Beta 2. This is great, because it means that all of the algorithms in Algorithms that take a parameter of IList<T> can be used on arrays, as well as other collections.

However, this support was made more limited in Beta 2. In Beta 2, when you get the IList<T> interface on an array, it is a read-only list. This means that you can read items in the array, but you cannot change the array via the IList<T> interface. The IList<T>.ReadOnly property returns true to indicate this, and using the indexer to change an item throws an NotSupportedException. After some searching around, I found a posting from the BCL team that described this limitation.

The upshot is that you can stiill use non-modifying generic algorithms on an array (for example, Algorithms.LastIndexOf). However, a generic algorithm that modifies the list (for example, Algorithms.StableSortInPlace) cannot be used directly on an array. An annoying limitation, to be sure.

My current thinking is to provide a method on Algorithms that creates a read-write IList<T> wrapper on an array. Something like:

IList<T> AsReadWriteList(T[] array);

Other ideas (or a better name) welcome.