C# Array + Random Swap

 
C# Array + Random Swap
 

   Form1.cs
 
   int[] indexPosition = new int[8]{0,1,2,3,4,5,6,7};
   string temp1;
   string temp2;
   int tempindex1;
   int tempindex2;
 
   BoxHeader[indexPosition[0]] = "HAHO";
   BoxHeader[indexPosition[1]] = "HKEC";
   BoxHeader[indexPosition[2]] = "HKWC";
   BoxHeader[indexPosition[3]] = "KCC";
   BoxHeader[indexPosition[4]] = "KEC";
   BoxHeader[indexPosition[5]] = "KWC";
   BoxHeader[indexPosition[6]] = "NTEC";
   BoxHeader[indexPosition[7]] = "NTWC";
 
   BoxLink[indexPosition[0]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=147&hid=459";
   BoxLink[indexPosition[1]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=148&hid=460";
   BoxLink[indexPosition[2]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=149&hid=461";
   BoxLink[indexPosition[3]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=150&hid=462";
   BoxLink[indexPosition[4]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=151&hid=463";
   BoxLink[indexPosition[5]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=152&hid=464";
   BoxLink[indexPosition[6]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=153&hid=465";
   BoxLink[indexPosition[7]] = "Catalog.aspx?PKeyId=37&Lang=Chi&CKeyId=154&hid=466";
 
   Random random = new Random();
 
   for (int i = 0; i < 5000; i++)
   {
      tempindex1 = random.Next(0, 7);
      temp1 = BoxLink[indexPosition[tempindex1]];
      temp2 = BoxHeader[indexPosition[tempindex1]];
 
      tempindex2 = random.Next(0, 7);
      BoxLink[indexPosition[tempindex1]] = BoxLink[indexPosition[tempindex2]];
      BoxHeader[indexPosition[tempindex1]] = BoxHeader[indexPosition[tempindex2]];
 
      BoxLink[indexPosition[tempindex2]] = temp1;
      BoxHeader[indexPosition[tempindex2]] = temp2;
   }