I have a method which takes a 2-dimensional array as argument.
void Process(object[,] array)
{
// do something
}
This method can also be used for 2-dimensional arrays which have only one 'row', e.g for variables like:
object[,] flatArray = new object[N,1];
I have 1-dimensional arrays which I want to treat as 2-dimensional arrays now. The best solution I could come up with is:
private object[,] Make2D(object[] array)
{
object[,] result = new object[array.Length, 1];
for(int i = 0; i < array.Length; i++)
{
result[i, 0] = items[i];
}
return result;
}
Is there a more efficient / clever way to do that?