I have N multidimensional source datasets, each of which has the same number of columns (C = 4 in this example), but any number of rows:
var array1 = new double[,]
{
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 9, 10, 11, 12 }
};
var array2 = new double[,]
{
{ 1, 2, 5, 6 },
{ 7, 8, 9, 10 },
{ 9, 10, 11, 12 }
};
var array3 = new double[,]
{
{ 1, 2, 7, 8 },
{ 13, 14, 15, 16 }
};
...
var arrayN = new double[,] { ... };
I also have an array that indicates which indexes in the source arrays should be used as join keys:
var keyArray = new int[] { 0, 1 };
I need to combine arrays so that the resulting array looks like this:
var result = new double[,]
{
{ 1, 2, 3, 4, 1, 2, 5, 6, 1, 2, 7, 8 },
{ 5, 6, 7, 8, null, null, null, null, null, null, null, null },
{ 9, 10, 11, 12, 9, 10, 11, 12, null, null, null, null },
{ null, null, null, null, 7, 8, 9, 10, null, null, null, null },
{ null, null, null, null, null, null, null, null, 13, 14, 15, 16 }
};
I think I need to select different keys from each source array and skip all the data and compare each row, etc., to populate the results array. However, there should be a more efficient way to do this with LINQ - can anyone help?