I never thought about adding using the Insert, just the Add.  Thanks.

-----Original Message-----
From: Chris Anderson [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 10:38 AM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] enumerating a collection while adding more items
to it


It depends

If you remove the item that's current, you don't increment the index,
because the index now points to the next item, if you insert an item after
the current one, you add 2 to the index (assuming you want to skip the new
item), otherwise you increment the index by one

Merak

> -----Original Message-----
> From: franklin gray [mailto:[EMAIL PROTECTED]]
> Sent: 10 June 2002 16:10
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] enumerating a collection while adding
> more items to it
>
>
> but when you remove an item from the collection/arraylist,
> doesn't that change the indexing?
>
> -----Original Message-----
> From: Chris Anderson [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 10, 2002 10:08 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] enumerating a collection while adding
> more items to it
>
>
> Alternatively don't use foreach, loop through using one of
> the other loop syntaxes, and decide what you want to do with
> the index variable you are using when you add/delete items
>
> Merak

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to