Wednesday, 11 September 2013

Combining two double[] arrays into double[,]

Combining two double[] arrays into double[,]

I frequently have two arrays that I need to combine to one matrix (same
lenght and type). I was wondering whether there is a linq way that is more
elegant than:
var result = new double[dt.Count, 2];
for (int i = 0; i < dt.Count; i++)
{
result[i, 0] = dts[i];
result[i, 1] = dt[i];
}
I tried
var result = dts.zip(dt, (a,b) => new{a,b})
and:
var result = dts.Concat(dt).ToArray()
But neither do what I would like to do...

No comments:

Post a Comment