foreach (var row in table.Rows) { DoSomethingWith(row); }
Assuming that I\'m working with a standard System.Data.DataTable (which has
System.Data.DataTable
That's because Rows is DataRowCollection, which in turn is IEnumerable and not IEnumerable, which means that type inferred will be object.
Rows
DataRowCollection
IEnumerable
object
When you explicitly state type in foreach, you instruct c# to add cast to each call, which is why it works.
foreach