Randomize

public static void Randomize<t>(this IList<t> target)
        {
            Random RndNumberGenerator = new Random();
            SortedList<int, t> newList = new SortedList<int, t>();
            foreach (t item in target)
            {
                newList.Add(RndNumberGenerator.Next(), item);
            }
            target.Clear();
            for (int i = 0; i < newList.Count; i++)
            {
                target.Add(newList.Values[i]);
            }
        }
Example:
 List<int> intList = new List<int>();
            intList.Add(1);
            intList.Add(2);
            intList.Add(3);
            intList.Add(4);
            intList.Add(5);
intList.Randomize(); // this will randomize the items in the list

Description

Randomize the Items in the list

Details

Double click on the code to select all.

 

;