title: How can I set all negative values in a dictionary to be zero?
body: <p>Working on a lil' c# browser game where I use this dictionary to keep track on several resources in the game:</p>
  
  <pre><code>public Dictionary &lt;String, int&gt; resource = new Dictionary&lt;string,int&gt;();
  </code></pre>
  
  <p>Amoungst those, "gold", which changes for each tick. </p>
  
  <pre><code>protected void timerMinute_Tick(object sender, EventArgs e)
  {
  resource["gold"] += (resProduction["gold"] - resConsumption["gold"])
  }
  </code></pre>
  
  <p>Now, if consumption is greater than production, the number decreases. I want to deny the resource from becoming negative. I know that I can do this for each tick:</p>
  
  <pre><code>if (resource["gold"] &lt; 0)
  {
  resource["gold"] = 0;
  }
  </code></pre>
  
  <p>However, I have many many more resources to keep track on, so while I could write the aforementioned code for each, I just wondered if someone had a clever way to check all values in the dictionary <em>resource</em>, and turn any negatives into zero.</p>
  
  <p>Edit: Thanks for all the great suggestions to the problem here! As a newbie with c#, I'm not quite familiar with it all ^^</p>