How to modify the properties of item inside Dictionary?
<p>I have a Dictionary, and I want to modify the property of an item inside the dictionary, how to achieve this? Can I use foreach to modify the item's properties? I has surveyed some posts, they said the reference obtained from foreach is readonly, which can not be modified.</p>

<pre><code>class MyClass
{
   public int propA { get; set; }
   public string propB { get; set; }
}

class Foo
{
   private Dictionary&lt;int, List&lt;MyClass&gt;&gt; mItemMap;

   ....
   public void QueryAndModify() {
      // My original thought, find what i want by foreach
      foreach(KeyValuePair&lt;int, List&lt;MyClass&gt;&gt; kvp in mItemMap) {
          foreach(MyClass item in kvp.Value) {
            // Can I modify the propB of item by this way ?
            if (item.propA == 3) {
                item.propB = "I got you.";
            }
          }
      }
   }
}
</code></pre>
