![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
In the design of .NET Framework Class Library, the IEnumerable is used to iterate through elements of collections. That iteration is not necessarily sequential and also for some special classes sequential iteration does not make sense. System.Array implements IEnumerable interface and in most cases it is useful to access it's elements sequentially. I'd like to use IEnumerable interface (using foreach keyword in most cases) in order to iterate but I did not find it documented that System.Array's implementation of that interface performs sequential iteration. .NET Framework v1.1 does it sequentially but I am looking for this to be documented; because I feel it that microsoft rarely violates the documentation of older versions. I like my codes to run in future versions of the product. So I do not use foreach on arrays where sequential iteration is required only if I find an explicit documentation of the issue. Anybody could help? Is this what you are looking for? |
#3
| |||
| |||
|
|
jamal (AT) docUSA (DOT) com> wrote in message news:%23fj9cd$yEHA.1260 (AT) TK2MSFTNGP12 (DOT) phx.gbl... In the design of .NET Framework Class Library, the IEnumerable is used to iterate through elements of collections. That iteration is not necessarily sequential and also for some special classes sequential iteration does not make sense. System.Array implements IEnumerable interface and in most cases it is useful to access it's elements sequentially. I'd like to use IEnumerable interface (using foreach keyword in most cases) in order to iterate but I did not find it documented that System.Array's implementation of that interface performs sequential iteration. .NET Framework v1.1 does it sequentially but I am looking for this to be documented; because I feel it that microsoft rarely violates the documentation of older versions. I like my codes to run in future versions of the product. So I do not use foreach on arrays where sequential iteration is required only if I find an explicit documentation of the issue. Anybody could help? Is this what you are looking for? quote A type that implements IEnumerable is also a collection type, even if it does not satisfy the conditions above. (This is possible if it implements some of the IEnumerable members by means of explicit interface member implementation, as described in Section 13.4.1.) The System.Array type (Section 12.1.1) is a collection type, and since all array types derive from System.Array, any array type expression is permitted in a foreach statement. The order in which foreach traverses the elements of an array is as follows: For single-dimensional arrays, elements are traversed in increasing index order, starting with index 0 and ending with index Length - 1. unquote Found in: http://msdn.microsoft.com/library/de...us/csspec/html |
| -- Peter [MVP Visual Developer] Jack of all trades, master of none. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |