title: Dictionary with class as Key
body: <p>I am studying electronic engineering, and I am a beginner in C#. I have measured data and I would like to store it in a 2 dimensional way. I thought I could make a <code>Dictionary</code> like this:</p>
  <pre><code>Dictionary&lt;Key, string&gt; dic = new Dictionary&lt;Key, string&gt;(); 
  </code></pre>
  <p>&quot;Key&quot; here is my a own class with two int variables. Now I want to store the data in this <code>Dictionary</code> but it doesn't work so far. If I want to read the data with the special Key, the error report says, that the Key is not available in the <code>Dictionary</code>.</p>
  <p>Here is the class Key:</p>
  <pre><code>public partial class Key
  {
      public Key(int Bahn, int Zeile) {
      myBahn = Bahn;
      myZeile = Zeile;
  
  }
      public int getBahn()
      {
          return myBahn;
      }
      public int getZeile()
      {
          return myZeile;
      }
      private  int myBahn;
      private int myZeile;
  }
  </code></pre>
  <p>for testing it I made something like this:</p>
  <p>Getting elements in:</p>
  <pre><code>Key KE = new Key(1,1);
  dic.Add(KE, &quot;hans&quot;);
  ...
  </code></pre>
  <p>Getting elements out:</p>
  <pre><code>Key KE = new Key(1,1);
  monitor.Text = dic[KE];
  </code></pre>
  <p>Has someone an idea?</p>