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

Dr Spack45 reputationPosted May 29, 2008, 7:07 AM EDT
You are right. There is no problem with changing the values in a Dictionary within a foreach loop.
DrSpack
George GeorgeRank #1,735 · 870 reputationPosted May 31, 2008, 4:08 AM EDT
Thanks Dr Spack,
Question answered.
regards,
George