George George

George George

  • NA
  • 778
  • 0

foreach Dictionary

May 27 2008 9:58 AM

Hello everyone,


If we use foreach to iterate a Dictionary, it is only restricted that we can not insert new elements and remove exsting elements of the Dictionary.

And we are free (allowed) to change the content (mmber fields) of object pointed by the "value" reference of a key, right? Example,

[Code]
foreach (KeyCollection<> k in someDictionary)
{
    // some operation will change the member fields of related object instance
    // pointed by "value" refernece of the related key k
    someDictionary[k].someOperation();
}
[/Code]


thanks in advance,
George


Answers (2)