I need a bit of a steer on this DataTable concept. I'm storing data in a DataTable which I initialise by first adding a column like so:
DataTable outputData = new DataTable();
outputData.Columns.Add("Reference/Group");
Now if I write this out to a CSV file (using my own class), I get what you'd expect, a view in spreadsheet software like:
A
1 Reference/Group
Yet when I go on in my script to assume that row 1 exists (by referencing outputData.Rows[0]) I get:
Exception: There is no row at position 0.
However if I try to add a row with the above content, it complains there's no column. If I specify the column then add a row, I can reference Rows[0] but by then I've got TWO rows like:
A
1 Reference/Group
2 Some new row
What's the correct approach here and what is the reason for this behaviour?