This is my code for order the first N element randomly in a List :
int upper = 1;
if (myList.Count > 1)
{
Random r = new Random();
upper = Math.Min(maxNumberOfPackets, myList.Count);
for (int i = 0; i < upper; i++)
{
int randInd = r.Next(i, myList.Count);
var temp = myList[i];
myList[i] = myList[randInd];
myList[randInd] = temp;
}
}
well, now I have the "necessity" to use only Enumerable (for some reason; so I don't want to convert it in a Enumerable).
For your knowledge, can I do the same with Enumerable? I think the pain is access to element at the X position...
I'm so curious...