I am using a DataTable
for some calculations in my app. I need to do the iterate trough all the rows except the first one. Is it possible?
Something like:
DataTable dt;
foreach (DataRow r in dt.Rows /*EXCEPT THE FIRST ONE*/)
{
//do something...
}
LINQ is your friend:
The call to
Cast()
is required here sinceDataTable.Rows
implements the non-genericIEnumerable
, and linq's extension methods are only available forIEnumerable<T>
You also have another option:
Ok you got your answers but in case you donT want to use linq. Check the index of the row in the table:
Here's a quick and dirty