Is it safe to delete from SortedList during iteration
Posted
by Captain Comic
on Stack Overflow
See other posts from Stack Overflow
or by Captain Comic
Published on 2010-04-23T12:35:10Z
Indexed on
2010/04/23
12:43 UTC
Read the original article
Hit count: 237
Hi,
My question is is it safe for enumerator to remove item from SortedList?
SortedList<decimal, string> myDictionary;
// omitted code
IEnumerator<decimal, string> enum = myDictionary.GetEnumerator();
while(enum.MoveNext)
{
// is it ok to remove here?
myDictionary.Remove(enum.Current.Key);
}
© Stack Overflow or respective owner