Re: IEnumerable interface implemented by System.Array
From: Peter van der Goes (p_vandergoes_at_toadstool.u)
Date: 11/16/04
- Next message: Eric: "Use DLL in Windows app problem"
- Previous message: jamal_at_docUSA.com: "IEnumerable interface implemented by System.Array"
- In reply to: jamal_at_docUSA.com: "IEnumerable interface implemented by System.Array"
- Next in thread: jamal_at_docUSA.com: "Re: IEnumerable interface implemented by System.Array"
- Reply: jamal_at_docUSA.com: "Re: IEnumerable interface implemented by System.Array"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 16 Nov 2004 11:35:57 -0600
<jamal@docUSA.com> wrote in message
news:%23fj9cd$yEHA.1260@TK2MSFTNGP12.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:
-- Peter [MVP Visual Developer] Jack of all trades, master of none.
- Next message: Eric: "Use DLL in Windows app problem"
- Previous message: jamal_at_docUSA.com: "IEnumerable interface implemented by System.Array"
- In reply to: jamal_at_docUSA.com: "IEnumerable interface implemented by System.Array"
- Next in thread: jamal_at_docUSA.com: "Re: IEnumerable interface implemented by System.Array"
- Reply: jamal_at_docUSA.com: "Re: IEnumerable interface implemented by System.Array"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|