If you still want to add to the end, (quicker than insert, etc) don't check the index against the number of entries, instead check it against a cached number of entries (ie read the length of the array first, then use *this* value when looping (I purposefully didn't say iterating<g>)
If you then decrement this maximum if you remove, but not increment it when adding, you will stop looping at the original last entry (thus ignoring all the new items) Merak > -----Original Message----- > From: franklin gray [mailto:[EMAIL PROTECTED]] > Sent: 10 June 2002 17:04 > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET] enumerating a collection while adding > more items to it > > > 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 > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.