In C#, there is a way to randomize char array. Following program explains it clearly.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace array_sort { class Program { static void Main(string[] args) { char[] a = { '1', 'A', '2', 'B', '3', 'C' }; char[] randomArray = new char[a.Length]; int randomnumber; Random rnd = new Random(); for (int i = a.Length; i >= 1; i--) { randomnumber = rnd.Next(1, i + 1) - 1; randomArray[i - 1] = a[randomnumber]; a[randomnumber] = a[i - 1]; } foreach (char s in randomArray) { Console.Write(s + " , "); } Console.ReadKey(); } } }
Output
3 , 2 , 1 , A , C , B ,
_
More Examples