Question: I iterate a DataTable's rows using - 

```
DataTable dt = getDataTableFromSomeWhere();
DataRow row = null;
//for loop
row = dt.Rows[i];

```

How do I get the value of a column of the i-th row, by using the name of the column ? 
I can iterate the columns using dt.Columns[j], but thats not what I want.

Answer: 
Just use the [indexer taking a string parameter](http://msdn.microsoft.com/en-us/library/146h6tk5%28v=vs.110%29.aspx):

```
object value = row["ColumnName"];

```

EDIT: Assuming the value has been fetched in an appropriate type, I'd normally just cast to the CLR type you want:

```
int someIntegerValue = (int) row["ColumnName"];

```

Sometimes you may need two levels of casting (one to unbox and then another to perform an actual value conversion) but it depends on what you need.

I would recommend *against* converting to a string representation and then parsing that, unless you've really got no alternative. Excessive string conversions not only harm performance (usually not relevant) but they lead to sloppy type choices.
```
 string name = (string) row["ColumnName"];

```

or 

```
 int i = Convert.ToInt32( row["ColumnName"]);

```

referencing by name is tiny bit slower but way more readable.