CSharp examples for System:Array Shuffle
Shuffle a generic array
using System.Collections.Generic; using System;/*from ww w . ja v a2 s . co m*/ public class Main{ public static T[] Shuffle<T>(this T[] array) { var r = new Random(); for (int i = array.Length; i > 0; i--) { int j = r.Next(i); T k = array[j]; array[j] = array[i - 1]; array[i - 1] = k; } return array; } }