int [] X;
int [] Y;
DataRow thisRow = (DataRow)dtExcelRecords.Rows[i];
int[] X = Convert.ToInt32(thisRow["X"]);
int[] Y = Convert .ToInt32(thisRow["Y"]);
DataRow dr = dt.NewRow();
Firstly you are declaring the arrays X and Y twice, which is illegal; declare them at the point you will use them. Secondly you are trying to initialize an array with a single element value, which is again illegal. And thirdly, the last line declaring the variable
dr
serves no purpose whatsoever.
Your code should be something like:
DataRow thisRow = (DataRow)dtExcelRecords.Rows[i];
int X = Convert.ToInt32(thisRow["X"]);
int Y = Convert.ToInt32(thisRow["Y"]);
However, there is still no provision for the situation when the returned value is not a valid integer, nor are these values of any use since they are local to the
for
loop and will go out of scope and be lost as soon as the loop ends. I would suggest going back to your reference manuals and reading up on scope and arrays at the minimum.