title: Update value in c# dictionary object if value is something
body: <p>I am trying to update value in c# dictionary object if value is something.</p>
  
  <pre><code>Dictionary&lt;string, int&gt; Section = new Dictionary&lt;string, int&gt;()
  {
              {"a", 1},
              {"b", 0},
              {"c", 2},
              {"d", 0},
              {"e", 0},
              {"f", 0},
  };
  </code></pre>
  
  <ol>
  <li>I want to loop through Section object and if value= 2 i want to set it to 1</li>
  <li>I want to set the value = 1 from 4th element till end.(i.e, from "d" to "f")</li>
  </ol>
  
  <p>Thanks,</p>
  
  <p>Praveen</p>
  
  <p>I have tried,</p>
  
  <pre><code>foreach(var item in Section)
  {
     if(item.value == 2)
     {
       item.value == 1;
     }
  }
  </code></pre>