foreach with collections

This is a discussion on foreach with collections within the C# Programming forums, part of the General Programming Boards category; When using foreach on a collection, after the loop is done should the size of the collection reset? Is there ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    241

    foreach with collections

    When using foreach on a collection, after the loop is done should the size of the collection reset? Is there a way to make it so a foreach loop can be done again on that same collection?

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    You can do foreach loops as long and as complicated as you want, you just cannot modify the collection in a foreach loop.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. foreach Dictionary
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-27-2008, 10:01 AM
  2. foreach and IEnumerator
    By George2 in forum C# Programming
    Replies: 2
    Last Post: 04-30-2008, 08:01 AM
  3. converting c code to c++, the foreach statement
    By hwttdz in forum C++ Programming
    Replies: 2
    Last Post: 07-12-2006, 11:03 AM
  4. foreach construct vs for
    By subdene in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-18-2003, 06:10 PM
  5. Icon collections
    By _Elixia_ in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 07-12-2003, 04:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21