I have several enumerables with data from sensors
time_elapsed, speed_x, speed_y, speed_z, altitude, latitude, longitude…
Every list has the same number of elements.
I want to combine the data of all the lists into a sequence of Status items.
class Status
{
public int TimeElapsed {get; set; }
public double SpeedX {get; set; }
public double SpeedY {get; set; }
public double SpeedZ {get; set; }
...
}
I thought about using the Enumerable.Zip method, but it looks really cumbersome:
var statuses = time_elapsed
.Zip(speed_x, (a, b) => new { a, b})
.Zip(speed_y, (c, d) => new { c, d})
.Zip(speed_z, (e, f) => new { e , f})
.Select(x => new Status
{
Time = x.e.c.a,
SpeedX = x.e.c.b,
SpeedY = x.e.d,
SpeedZ = x.f
// ...
});
As you see, it's from from being readable with all those anonymous types.
Is there a better way to do it without losing your head?