I am trying to make a C# program that takes coordinates from an excel file in the sense that each column is x,y,z and r, respectively, and each row is a different point. I would like to be able to create variables in the format point0, point1, etc. depending on how many rows there are.
As of right now I am reading each cell into an Array, then manually creating points from that array. In this case there are 4 rows and 4 points (points 0 to 3). This works for now but I have to imagine there is a much easier way of doing this or at least something more dynamic. 4 points is not a big deal but there could be many more.
int rows = 4;
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < rows; j++)
{
points[i,j] = excel.ReadCell(i, j);
}
}
for(int i = 0; i < 4; i++)
{
point0[0, i] = points[0, i];
}
for (int i = 0; i < 4; i++)
{
point1[1, i] = points[1, i];
}
for (int i = 0; i < 4; i++)
{
point2[2, i] = points[2, i];
}
for (int i = 0; i < 4; i++)
{
point3[3, i] = points[3, i];
}
Even condensing the set of loops where the points are manually created would save time, I am just not sure if there is a way to say something such as
for(int i = 0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{
point+"i"[i,j] = points[i,j]
}
}
Where the ith iteration is concatenated to the variable name.
Any help would be greatly appreciated, and I am open to all recommendations (I am pretty new to C# if you can't tell)