title: C# Dictionary - The given key was not present in the dictionary
body: <p>I'm currently trying to load game objects from a Tiled (Tiled map editor) map file into a game engine I'm making in C#. I'm using TiledSharp (Link to github <a href="https://github.com/marshallward/TiledSharp/blob/master/TiledSharp/src/TiledCore.cs" rel="nofollow noreferrer">here</a>). It uses a dictionary to hold properties about each individual tile (or 'game object') I'm trying to load. But for some reason I get an error when I loop through the properties, and I also get an error if I check if it's null</p>
  
  <p>Here's a snippet of the code I'm using:</p>
  
  <pre><code>for (int l = 0; l &lt; tmxMap.Tilesets[k].Tiles.Count; l++)
      // This line throws an error
      if (tmxMap.Tilesets[k].Tiles[l].Properties != null)
          // and if I remove the above line, this line throws an error
          for (int m = 0; m &lt; tmxMap.Tilesets[k].Tiles[l].Properties.Count; m++)
  </code></pre>
  
  <p>The error I get says The given key was not present in the dictionary. But... I'm not even checking for a key.</p>
  
  <p>Am I missing something?</p>
  
  <p>Any help would be appreciated.</p>