How can I shuffle my list of strings?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/273313/randomize-a-listt-in-c">Randomize a List&lt;T&gt; in C#</a>  </p>
</blockquote>



<p>I thought I had my code working but now it seems not. Here's what I have:</p>

<pre><code>public class NoteDetail
{
    public NoteDetail()
    {
        _noteDetails = new List&lt;string&gt;();
    }
    public IList&lt;string&gt; NoteDetails { get { return _noteDetails; } }
    private readonly List&lt;string&gt; _noteDetails;
}
</code></pre>

<p>I populate my details like this:</p>

<pre><code>        var noteDetail = new NoteDetail ();
        noteDetail.NoteDetails.Add("aaa");
        noteDetail.NoteDetails.Add("bbb");
        noteDetail.NoteDetails.Add("ccc");
</code></pre>

<p>Now I want to shuffle so I used this routine:</p>

<pre><code>    public static void ShuffleGenericList&lt;T&gt;(IList&lt;T&gt; list)
    {
        //generate a Random instance
        var rnd = new Random();
        //get the count of items in the list
        var i = list.Count();
        //do we have a reference type or a value type
        T val = default(T);

        //we will loop through the list backwards
        while (i &gt;= 1)
        {
            //decrement our counter
            i--;
            //grab the next random item from the list
            var nextIndex = rnd.Next(i, list.Count());
            val = list[nextIndex];
            //start swapping values
            list[nextIndex] = list[i];
            list[i] = val;
        }
    }
</code></pre>

<p>My problem is that I am not sure how to do the shuffle. I have tried the following but it gives: </p>

<blockquote>
  <p>Error 237 Argument 1: cannot convert from 'System.Collections.Generic.IList' to 'System.Collections.Generic.IList&lt;.Storage.Models.NoteDetail>'</p>
</blockquote>

<pre><code>Sort.ShuffleGenericList&lt;NoteDetail&gt;(noteDetail.NoteDetails);
</code></pre>

<p>Can anyone see what I am doing wrong. It all looks okay to me and I can't see why I should get this error :-(</p>
