I was pretty surprised when I discovered that there is no direct way to sort or perform a binary search on an IList< T >. Just like there are static methods to sort and perform a binary search on an Array, I think that it would be awfully helpful to have similar static methods that take an IList< T >.
Currently:
class Array
{
static Sort<T>(T[] array);
static int BinarySearch<T>(T[] array, T item);
}
I wish they would add:
class List
{
static Sort<T>(IList<T> list);
static int BinarySearch<T>(IList<T> list, T item);
}
I glanced at the .NET Framework 4.0 Beta SDK and there still doesn't appear to be a solution to this problem.
I know that I could work around this by creating an extension method that checks if it is a List< T > and then sort/search using the List< T > instance; however, if it is not an instance of a List< T >, then I have to perform a copy (which stinks for very large lists). I know I could do all of this, but why? Is there some reason they have intentionally omitted this feature?
To try to get this in the .NET 4.0 Framework, I have created a suggestion via Microsoft's Connect program. If you are frustrated like me about this issue, vote on it and maybe it will get added.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=474201