Re: Removing an object from an Enumerated Collection
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Thu, 05 Jun 2008 09:56:33 +0200
gee-dub wrote:
Hi,
I need to remove an object from a collection that has been enumerated
with GetEnumerator similar to this...
With lobjs.GetEnumerator
.MoveNext()
if [some_condition] Then
lobjs.remove(.Current)
end if
end with
I realise you can't use the Remove with the GetEnumerator and bombs on
the next MoveNext. is there another way to do this? The API I'm
using requires GetEnumerator (as opposed to For...Each).
Cheers!
The For Each uses an enumerator, so unless the enumerator is crap, there is no problem in using a For Each.
As Stephany suggested, to remove the items you just put them in a new list, and remove them in a separate loop.
--
Göran Andersson
_____
http://www.guffa.com
.
- References:
- Removing an object from an Enumerated Collection
- From: gee-dub
- Removing an object from an Enumerated Collection
- Prev by Date: Re: SaveFileDialog.ShowDialog() returns Cancel when Yes to overwrite ...
- Next by Date: Re: How to create service that acts on Alt+Print Screen?
- Previous by thread: Re: Removing an object from an Enumerated Collection
- Next by thread: Re: Removing an object from an Enumerated Collection
- Index(es):
Relevant Pages
|