HighTechTalks DotNet Forums  

IEnumerable interface implemented by System.Array

Dotnet Academic General Discussions microsoft.public.dotnet.academic


Discuss IEnumerable interface implemented by System.Array in the Dotnet Academic General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
 
Posts: n/a

Default IEnumerable interface implemented by System.Array - 11-16-2004 , 11:10 AM






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?





Reply With Quote
  #2  
Old   
Peter van der Goes
 
Posts: n/a

Default Re: IEnumerable interface implemented by System.Array - 11-16-2004 , 12:35 PM







<jamal (AT) docUSA (DOT) com> wrote

Quote:
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...spec_8_8_4.asp


--
Peter [MVP Visual Developer]
Jack of all trades, master of none.






Reply With Quote
  #3  
Old   
 
Posts: n/a

Default Re: IEnumerable interface implemented by System.Array - 11-20-2004 , 11:14 AM



Exactly,
Many thanks.

"Peter van der Goes" <p_vandergoes (AT) toadstool (DOT) u> wrote

Quote:
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
/vclrfcsharpspec_8_8_4.asp
Quote:

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.