Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is there no Sort for IList<T>?!?! (edited)
    text
    copied!<p>I was pretty surprised when I discovered that there is no direct way to sort or perform a binary search on an IList&lt; 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&lt; T >.</p> <p>Currently:</p> <pre><code>class Array { static Sort&lt;T&gt;(T[] array); static int BinarySearch&lt;T&gt;(T[] array, T item); } </code></pre> <p>I wish they would add:</p> <pre><code>class List { static Sort&lt;T&gt;(IList&lt;T&gt; list); static int BinarySearch&lt;T&gt;(IList&lt;T&gt; list, T item); } </code></pre> <p>I glanced at the .NET Framework 4.0 Beta SDK and there <strong>still</strong> doesn't appear to be a solution to this problem.</p> <p>I know that I could work around this by creating an extension method that checks if it is a List&lt; T > and then sort/search using the List&lt; T > instance; however, if it is not an instance of a List&lt; 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?</p> <p>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.</p> <p><a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=474201" rel="noreferrer">https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=474201</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload