Possible Duplicate:
C#: Is using Random and OrderBy a good shuffle algorithm?
I want to create an extension method which should shuffle the items in the collection.
Can i improve the following?
public static IList<T> RandomList<T>(this IList<T> source)
{
if (source.Count <= 0) throw new ArgumentException("No Item to Randomize");
for (int i =source.Count-1 ; i>0; i--)
{
int RandomIndex = Rnd.Next(i + 1);
T temp = source[i];
source[i] = source[RandomIndex];
source[RandomIndex] = temp;
}
return source;
}