foreach (DataRow row in myDataTable.Select())
foreach (DataRow row in myDataTable.AsEnumerable())
foreach (DataRow row in myDataTable.Rows)
Any differences?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Rowsisn’t strongly typed – so there will be a cast on each iteration, and you can’t use LINQ to objects on it easily. (I believeAsEnumerable()will have to cast on each iteration internally as well, but at least you can use it for other LINQ methods easily.)Selectneeds to build an array, so there’s obviously a performance penalty there.Personally I’d use
AsEnumerable()unless you wanted to modify the table within the loop, in which case the fact thatSelectbuilds an array up-front may actually be an advantage.