How to get max 10 random items from list?
<p>I have a list that can have a variable amount of items (but no more than ~30 so no performance issue here), I want to get maximum 10 random items and I wrote a piece of code for that which works fine if there are 10+ items in the list. The issue with the code below is that it obviously doesn't randomize the result if there are less than 10 items in the list and if there are less than 10 items I want to display them all but in random order.</p>

<pre><code>var keyPersons = people.ToList();
Random rnd = new Random();
while (keyPersons.Count() &gt; 10)
{
    int j = rnd.Next(0, keyPersons.Count());
    keyPersons.RemoveAt(j);
}

rptKeyPersons.DataSource = keyPersons;
</code></pre>

<p>How can I randomize the result if there are let's say only five items in the person list?</p>

<p>Thanks in advance.</p>
