C# DataTable, get value by Row/Column index

Viewed 30273

I have a DataTable which is populated by a csv file, with 8 columns and approximately 2000 rows. I wish to populate an object with my csv values that are currently stored in my DataTable

How do I index a specific DataTable cell? In other words, I wish to treat the data table in a similar way you would a 2D array, like so:

string value = array[i][j];

Here is my code:

DataTable d = GetDataTableFromCSVFile(file);
for (int i = 0; i < d.Rows.Count; i++)
{
    for (int j = 0; j < d.Columns.Count; j++)
    {
         //string x = d[i][j]; <-- something like this.
    }
} 
3 Answers
Related