title: C# Infinite While Loop using ContainsValue with nested Dictionary
body: <p>I have this script in PHP where I use </p>
  
  <blockquote>
    <p>while( in_array(array('x' => $x, 'y' => $y), $worldMap) ){ ... }</p>
  </blockquote>
  
  <p>to check if my worldMap already have a room at those XY positions.
  IF TRUE I randomize either X or Y and the WHILE loop check again with the new values and so on, IF FALSE I populate the worldMap array with last XY generated.</p>
  
  <p>Now, I'm trying to rewrite that code in C# but I'm getting an infinite Loop.</p>
  
  <p>Here's my current Code:</p>
  
  <pre><code>public int nbRooms = 10;
  
  private Dictionary&lt;int, Dictionary&lt;string, int&gt;&gt; worldMap = new Dictionary&lt;int, Dictionary&lt;string, int&gt;&gt;();
  private Dictionary&lt;string, int&gt; roomXY = new Dictionary&lt;string, int&gt;();
  
  private string[] arrayXY = {"X","Y"};
  private int[] arrayNbr = {-1,1};
  private int X = 0;
  private int Y = 0;
  
      for(int i = 0; i &lt;= nbRooms; i++)
      {
          while(worldMap.ContainsValue(roomXY))
          {
              string XorY = arrayXY[Random.Range(0, 2)];
  
              switch(XorY)
              {
              case "X": X += arrayNbr[Random.Range(0, 2)];
                  break;
              case "Y": Y += arrayNbr[Random.Range(0, 2)];
                  break;
              }
  
              roomXY.Clear();
              roomXY.Add("X", X);
              roomXY.Add("Y", Y);
          }
  
          worldMap.Add(i, roomXY);
      }
  </code></pre>