KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When I enter this foreach statement... foreach (var row in table.Rows) ...the tooltip for var says class System.Object I'm confused why it's not class System.Data.DataRow . (In case you're wondering, yes, I have using System.Data at the top of my code file.) If I declare the type explicitly, as in... foreach (DataRow row in table.Rows) ...it works fine with no errors. Also if I do... var numbers = new int[] { 1, 2, 3 }; foreach (var number in numbers) ...var evaluates to struct System.Int32 . So, the problem is not that var doesn't work in a foreach clause. So, there's something strange about DataRowCollection where the items don't automatically evaluate to DataRow . But I can't figure out what it is. Does anyone have an explanation? Update I was really torn which answer to mark (Codeka and Oliver)...In the end, I decided to mark Codeka's because it truly answers my question, but Oliver answers the question I should have been asking :)
Tags (comma-separated)
Save Edits
Cancel