开发者

Does A dataTable.Rows.Count Get Evaluated On Each Loop?

开发者 https://www.devze.com 2022-12-21 14:13 出处:网络
I just wonder if I do something like for (int i = 0; i < dataTable.Rows.Count; i++) Does array.Count get revaluated on each iteration?

I just wonder if I do something like

for (int i = 0; i < dataTable.Rows.Count; i++)

Does array.Count get revaluated on each iteration?

The reason I ask is becua开发者_StackOverflow中文版se if I delete rows from that datatable will that cause problems?


Yes, it does get evaluated each time, but you really shouldn't be changing the number of elements you are iterating through like that.

0

精彩评论

暂无评论...
验证码 换一张
取 消