Identify a column in a DataTable


Dear community

I’m wondering about a Quiz question and I could not find the answer. How am I able to identify a column in a DataTable? I believe, it’s with using the column index (0), as an example. But it might also be via the column name…
Question for the Quiz: who knows which on is the correct answer? Or do I understand it wrong? I assume it’s to identify the column to read data… is this correct?


That’s the correct answer. We can read the column using either column name or column index.


Thank you, that’s what I thought and programmed but wasn’t sure weather it’s the right answer as well.


We can use Column Name or Column Index to identify a column,

Example if you are using DataRow, you can get any specific column by

> MyDataRow.Item("<columnName>").ToString 
> MyDataRow.Item(<columnIndex>).ToString