Why and when we need to convert arraylist into array in C#? If we have some data in RAM memory (arraylists) and want to sort the data in one arraylist by another arraylist (they have to be the same size), we can utilize Array class in C#, but we must convert arraylist into array in C# first. To do so, we can simply use these lines of code:
double dbl_array_values1 = alValues1.ToArray(typeof(double)) as double;
double dbl_array_values2 = alValues2.ToArray(typeof(double)) as double;
Then we can simply sort an array by another in C#, value2 by value1 for example with following line of code:
So dbl_array_values1 will be sorted automatically and dbl_array_values2 will be sorted by dbl_array_values1.