Is there a reason why I can't do the following:
foreach (var Item in DataTable.Rows) {
rather than having to do
foreach (DataRow Item in DataTable.Rows) {
I would have thought this was possible, like it is on other datatypes. For example:
foreach (var Employee in Staff) { // string[] Staff etc...
When I try the first foreach loop, I get the the error CS0021: Cannot apply indexing with [] to an expression of type 'object'.
Why can't the compiler figure out that .Rows returns a collections of DataRows?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…