Expand|Select|Wrap|Line Numbers
- Private Sub Test()
- For Each row As DataRow In dtMyTable.Rows
- Debug.Print("{0}", row(0))
- Next
- End Sub
- Private Sub Test2()
- If dtMyTable.Rows.Count > 0 Then
- For Each row As DataRow In dtMyTable.Rows
- Debug.Print("{0}", row(0))
- Next
- End If
- End Sub
I'm new at reading IL. It appears that if the table contains some rows, two instances of the dataTable is created in the Test2 method. One to check the RowCount and another to invoke the enumerator logic. Does the IL reuse these instances?
I know this might be really splitting hairs but I'd be interested in the best choice for optimum performance. Thanks for your thoughts.