I'm probably not wording the question correctly, so please help me on the nomenclature.
If I have a List<Point>
which has a constant set of x
values, but a variable stream of y
values. Right now I have:
List<DataPoint> points = new List<DataPoint>();
while(...)
{
double data[] = ...
for (int i = 0; i < data.Length; i++)
points.Add(new DataPoint(i, data[i]));
}
But I feel like it should be possible to use LINQ:
points.Select(y => y.AddRange(data));
I don't need to change the x
values. Also, I'm asking because I'm trying to increase processing performance on this loop somehow, so if there's a faster way, please enlighten me.
You can use Linq to create all the values you want to add then use
AddRange
.But please note that this will probably not be any faster than your
for
loop.