Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/05/2012, 13:36
posman
 
Fecha de Ingreso: enero-2008
Mensajes: 614
Antigüedad: 17 años, 1 mes
Puntos: 57
Respuesta: For Each In Vs For To

No se si sirva de mucho

Cita:
Collections

When you traverse a collection, you can use either a For loop or a For Each loop. If you expect to add, delete, or rearrange elements of the collection during the traversal, a For loop can produce more reliable results. It also allows you to determine the order of traversal. Furthermore, a collection derived from the CollectionBase class in the System.Collections namespace throws an exception if you attempt to change its members during a For Each loop.

A For Each loop gives control of the collection to the enumerator object returned by the IEnumerable.GetEnumerator method. This means that you cannot necessarily predict the order of traversal. For Each is useful when you are not able to access a collection's members using the Item property.

The performance difference between For and For Each loops does not appear to be significant.
http://msdn.microsoft.com/en-us/libr...perfoptanchor5