Consider:
float[] xPos = new float[pt3f.Count];
float[] yPos = new float[pt3f.Count];
float[] zPos = new float[pt3f.Count];
for (int i = 0; i < pt3f.Count; i++)
{
xPos[i] = pt3f[i].X;
yPos[i] = pt3f[i].Y;
zPos[i] = pt3f[i].Z;
}
I know that I can use LINQ here
var xPos = pt3f.Select(I => I.X).ToArray();
var yPos = pt3f.Select(I => I.Y).ToArray();
var zPos = pt3f.Select(I => I.Z).ToArray();
so my questions are different from cleaner code using LINQ, are there any performance benefits?
I think in terms of performance, using one for-loop is faster, I'm right, i.e. 3 Linqs will eventually be converted to 3 cycles.
source
share