title: C# Dictionary can't find string key
body: <p>Am I going mad? Why does this return an exception!? Why can't it find the key? It's obviously there!</p>
  
  <pre><code>public class Spanning {
      Dictionary&lt;string, City&gt; graph = new Dictionary&lt;string, City&gt;();
  
      public static void Main(string[] args) {
          new Spanning().Parse("file.in");
      }
  
      public void Parse(string f) {
          string[] citySeparator = new string[] {"--"};
          using (StreamReader reader = new StreamReader(f)) {
              string line;
              while((line = reader.ReadLine()) != null) {
                  if (!line.Contains("--")) {
                      graph[line] = new City {name = line.Substring(0, line.Length - 1)};
                  } else {
                      string[] split = line.Split(citySeparator, StringSplitOptions.None);
                      City city1 = graph[split[0]];
                  }
              }
          }
      }
  
      class City {
          Dictionary&lt;City, int&gt; links = new Dictionary&lt;City, int&gt;();
          public string name;
  
          public override string ToString() {
              return name;
          }
      }
  }
  </code></pre>
  
  <p>Input file contains just two rows:</p>
  
  <pre><code>"San Diego" 
  "San Diego"--"San Antonio" [1319]
  </code></pre>