How to modify it's value while Enumerating?

  • Thread starter Thread starter Shelby
  • Start date Start date
S

Shelby

Hi,
I would like to modify the object's value while enumerating but I get this
error
Additional information: Collection was modified; enumeration operation may
not execute.

This is my code:

Dim icom as MyOwnStructureObj
Dim MyEnum As IDictionaryEnumerator = Myhash.GetEnumerator()
While MyEnum.MoveNext()
icom = MyEnum.Value
icom.myOwnProperty1 = "change value"

Myhash.Item(MyEnum.Key) = icom ' Error occurs here
End While

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top