user3185171 user3185171 - 1 year ago 86
C# Question

Creating multidimension list

I have seperate list of values reflecting X,Y,Z coordinates properties.

List<double> PointX;
List<double> PointY;
List<double> PointZ;

Is it possible to create a '3D List' such that i would have

Point = (PointX,PointY,PointZ)

Answer Source

You can use nested Zip calls to take values from each list:

var points = 
    PointX.Zip(PointY.Zip(PointZ, (y,z) => new {y, z})
            , (x, yz) => new Point(x, yz.y, yz.z));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download