title: create cross table structure with dictionary
body: <p>I want to create a datastore class that holds some goods and their amount. An example would be a shopping cart with some articles and their amount.</p>
  
  <p>This <code>Store</code> class should behave like a database cross table</p>
  
  <pre><code>ID | Amount
  -----------
  1  | 432
  2  | 52345234
  3  | 243545
  4  | 1123
  5  | 235345645
  6  | 3434
  7  | 33342
  8  | 5543
  9  | 665675
  10 | 3445
  </code></pre>
  
  <p>I thought about using a dictionary that holds the ID and the amount.</p>
  
  <pre><code>class Store
  {
      public Store()
      {
          goods = new Dictionary&lt;int, int&gt;();
  
          for (int i = 0; i &lt; 10; i++) // There might be 10 goods in the database
          {
              goods.Add(i, 0); // initialize with an amount of 0
          }
      }
  
      Dictionary&lt;int, int&gt; goods; // &lt;ID, Amount&gt;
  
      public void ChangeGoodAmount(int goodId, int goodAmountModifier) // add or remove goods
      {
          goods.Where(valuePair =&gt; valuePair.Key == goodId).First().Value += goodAmountModifier;
      }
  }
  </code></pre>
  
  <p>I can't modify the amount because the <code>Value</code> is readonly. Is a workaround possible or maybe there is a completely different way?</p>