vis781
Well-known member
I know this is dead lazy and i should do my own testing but can anyone tell me which of the following loops would execute faster...
Or..
Where 'al' would be an arraylist. I ask because i invariably always see people using for/next loops (that includes me) and i was thinkng that the getenumerator method would most likely get overlooked most of the time. Then i asked myself the question i wonder which one is faster? I'll have a go when i get back to my Dev PC tonight, but the mean time if anyone has a go i should be curious to know the result.
VB.NET:
Dim i As Integer
For i = 0 To al.Count - 1
Console.WriteLine(CStr(al.Item(i)))
Next
Or..
VB.NET:
Dim en As IEnumerator = al.GetEnumerator
While en.MoveNext
Console.WriteLine(en.Current)
End While
Where 'al' would be an arraylist. I ask because i invariably always see people using for/next loops (that includes me) and i was thinkng that the getenumerator method would most likely get overlooked most of the time. Then i asked myself the question i wonder which one is faster? I'll have a go when i get back to my Dev PC tonight, but the mean time if anyone has a go i should be curious to know the result.