CSharp examples for System.Collections.Generic:IEnumerable
Shuffle elements in random order. To get a random on the order used Random class.
using System.Security.Cryptography; using System.Linq; using System.Collections.Generic; using System;/*from ww w .j a va 2 s . c om*/ public class Main{ /// <summary> /// Shuffle elements in random order. To get a random on the order used Random class. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source"></param> /// <returns></returns> public static IEnumerable<T> FastShuffle<T>(this IEnumerable<T> source) { var rnd = new Random(); return source.OrderBy(item => rnd.Next()); } }