title: KeyNotFoundException in filled dictionary
body: <p>I am trying to modify value in dictionary, but the compiler throws <code>KeyNotFoundException</code>. I'm sure, I declared that key in dictionary, because I am calling <code>GenerateEmptyChunks()</code> method, which fills dictionary with chunks with key of their position and values are empty for level generator. I've checked debugger and <code>Chunks</code> dictionary object is correctly filled with keys and values. Is it caused by my unworking <code>CompareTo</code> method? If yes, how I have modify <code>CompareTo</code> method to return right values?</p>
  
  <pre><code>public Dictionary&lt;WPoint, WChunk&gt; Chunks = new Dictionary&lt;WPoint, WChunk&gt;();
  </code></pre>
  
  <p><em>GenerateEmptyChunks()</em> method:</p>
  
  <pre><code>public void GenerateEmptyChunks(int Xcount, int Ycount)
      {
          for(int x = 0; x &lt;= Xcount; x++)
          {
              for (int y = 0; y &lt;= Ycount; y++)
              {
                  this.Chunks.Add(new WPoint(x, y), new WChunk(x, y));
              }
          }
      }
  </code></pre>
  
  <p><em>AddBlock()</em> method which is called by level generator for each tile:</p>
  
  <pre><code>public void AddBlock(WPoint location, int data)
      {
          this.Chunks[location.GetChunk()].AddTile(new WTile(location, data));
      }
  </code></pre>
  
  <p><em>WChunk</em> object:</p>
  
  <pre><code>public class WChunk
      {
          public int ChunkX;
          public int ChunkY;
          public SortedDictionary&lt;WPoint, WTile&gt; Tiles = new SortedDictionary&lt;WPoint, WTile&gt;();
  
          public WChunk(int posX, int posY)
          {
              ChunkX = posX;
              ChunkY = posY;
          }
  
          public void AddTile(WTile tile)
          {
              Tiles.Add(tile.GetLocation(), tile);
          }
      }
  </code></pre>
  
  <p><em>WPoint</em> object:</p>
  
  <pre><code>public class WPoint : IComparable
      {
          public float X;
          public float Y;
  
          public WPoint(float x, float y)
          {
              X = x;
              Y = y;
          }
  
          public WPoint GetChunk()
          {
              //Oprava pre bloky mensie ako (1,1)
              if (X &lt;= 16 &amp;&amp; Y &lt;= 16)
              {
                  return new WPoint(0, 0);
              }
              else
              {
                  double pX = (double)(X / 16);
                  double pY = (double)(Y / 16);
                  return new WPoint((int)Math.Floor(pX), (int)Math.Floor(pY));
              }
          }
  
          public int CompareTo(object obj)
          {
              WPoint point2 = (WPoint)obj;
              if (point2.X == this.X &amp;&amp; point2.Y == this.Y)
              {
                  return 0;
              }
              else if (point2.X &gt;= this.X &amp;&amp; point2.Y &gt;= this.Y)
              {
                  return -1;
              }
              else
              {
                  return 1;
              }
          }
  }
  </code></pre>
  
  <p>Any ideas why is compiler rejecting keys, when they are in dictionary?</p>