469,267 Members | 979 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

foreach on Collection, List, IList, ICollection, ...

Hi all,

Can I assume that when I loop throw a Collection, List, IList,
ICollection, ... by using foreach, I first get the element of index 0,
then index 2, and so on until the last one ?

Thanks for your answers,

Dansk.
Jun 27 '08 #1
3 7574
No... It would go index 0 then index 1, index 2, so on.....
"Dansk" <da***@laouilest.frwrote in message
news:Ot**************@TK2MSFTNGP04.phx.gbl...
Hi all,

Can I assume that when I loop throw a Collection, List, IList,
ICollection, ... by using foreach, I first get the element of index 0,
then index 2, and so on until the last one ?

Thanks for your answers,

Dansk.
Jun 27 '08 #2
Dansk wrote:
Hi all,

Can I assume that when I loop throw a Collection, List, IList,
ICollection, ... by using foreach, I first get the element of index 0,
then index 2, and so on until the last one ?

Thanks for your answers,

Dansk.
Yes, you can expect this. This is an elementary requirement of the enumerator functionality.

--
Try Code-Navigator on http://www.codenav.com
a source code navigating, analysis and developing tool.
It supports following languages:
* C/C++
* Java
* .NET (including CSharp, VB.Net and other .NET components)
* Classic Visual Basic
* PHP, HTML, XML, ASP, CSS
* Tcl/Tk,
* Perl
* Python
* SQL,
* m4 Preprocessor
* Cobol
Jun 27 '08 #3

Thank you for your answers, they really make sense to me.
Dansk a écrit :
Hi all,

Can I assume that when I loop throw a Collection, List, IList,
ICollection, ... by using foreach, I first get the element of index 0,
then index 2, and so on until the last one ?

Thanks for your answers,

Dansk.
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

104 posts views Thread by cody | last post: by
6 posts views Thread by rodchar | last post: by
3 posts views Thread by Steve Barnett | last post: by
5 posts views Thread by Chuck Cobb | last post: by
28 posts views Thread by Michael Primeaux | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.