How to iterate a TDictionary and delete item?
问题 I have a TDictionary and add some items to it: for index := 0 to 10 do dict.Add(IntToStr(index), index); Now, I need to iterate the container and remove items I wanted: pairEnum := dict.GetEnumerator; while pairEnum.MoveNext do begin if pairEnum.Current.Value mod 2 = 0 then dict.Remove(pairEunm.Current.Key); end; I expect I now only have odd number in the dictionary. But what I actually got are: key=1 value=1 key=3 value=3 key=5 value=5 key=7 value=7 key=9 value=9 key=8 value=8 <- Why the "8"