Shuffle

public static IEnumerable<T> Shuffle<T>(this Enumerable<T> list) 
{
    var r = new Random((int)DateTime.Now.Ticks);
    var shuffledList = list.Select(x => new { Number = r.Next(), Item = x }).OrderBy(x => x.Number).Select(x => x.Item);
    return shuffledList.ToList();
}
Example:
var names = new List<string>();
names.Add("Harry");
names.Add("Dick");
names.Add("Tom");
var namesShuffled = names.Shuffle();
 

Description

Shuffles an IEnumerable list

Details

Double click on the code to select all.

 

;