CSharp examples for System.Collections.Generic:IList
Shuffle element in IList
using System.Collections.Generic; using System;/*w ww . j av a 2 s . c om*/ public class Main{ public static void Shuffle<T>(this IList<T> list) { var rng = new Random(); var n = list.Count; while (n > 1) { n--; var k = rng.Next(n + 1); var value = list[k]; list[k] = list[n]; list[n] = value; } } }