I have a question regarding DataRows
. I have a DataTable
which I then converted into a list of DataRow
's. Now I want the string information stored in each DataRow
. How can I do this? This is my code:
List<DataRow> list = dt.AsEnumerable().ToList();
You could do this,
foreach(var row in list)
{
var value = row["ColumnName"] as string;
}
or this to get all string values of "ColumnName" lazily.
var values = list.Select(row => row["ColumnName"] as string);
Why would you turn a DataTable into a list, though? Just wondering.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With