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
George GeorgePosted May 31, 2008, 8:08 AM
Thanks Dr Spack,
Question answered.
regards,
George
Dr SpackPosted May 29, 2008, 11:07 AM
You are right. There is no problem with changing the values in a Dictionary within a foreach loop.
DrSpack