mardi 1 novembre 2016

Randomly select element from array and assign it to list

I have a char array(A) and int array(B). I want to select elements randomly from array A and concatenate them with elements of array B from first element. Add the concatenated elements to a string list.

 List<string> AB_Concat = new List<string>();
        Random random = new Random();
        for(int i=0;i<26;i++)
       AB_Concat[i] = Convert.ToString(A[random.Next(i, A.Length)]) + Convert.ToString(B[i]);




        for (int i = 0; i < 26; i++)
            Console.Write(AB_Concat[i] + " ");




Aucun commentaire:

Enregistrer un commentaire