I am trying to implement a merge-sort in c# to try and learn the language. I am having trouble splitting the array in the divide step. I come from a c background and would do something like this:
void MergeSort(int array[], int size)
{
if (size == 1)
return;
MergeSort(array, size/2);
MergeSort(array + size/2, size - size/2);
}
My question is, can you do something similar in c#? I am aware there is take and skip methods, but is this the best way?
List<int>instead of the array (it is a class, so the reference is what gets passed, by value). And though you can use pointers with unsafe, that's not really the C# way.