title: KeyNotFoundException: The given key was not present in the dictionary C#
body: <p>I am sorry if this question is being asked because i missed something incredibly basic.</p>
  
  <p>I am getting<code>KeyNotFoundException</code> with the error: </p>
  
  <blockquote>
    <p>The given key was not present in the dictionary from Unity for a
    search for a Dictionary Key.</p>
  </blockquote>
  
  <p>Example code is added below. </p>
  
  <p>When I press GET DATA button on GUI it is working fine. But it is giving <code>KeyNotFoundException</code> when I press GET DATA CAST button on GUI.</p>
  
  <p>What I am missing? Any suggested changes that I need to make in code</p>
  
  <p>I inserted data into Dict, sorry I missed that to post here
  Class</p>
  
  <pre><code>[System.Serializable]
  public sealed class AnimName
  {
      public static readonly AnimName IDLE = new AnimName("IDLE");
  
      public AnimName(string value)
      {
          Value = value;
      }
      public string Value { get; private set; }
  }
  </code></pre>
  
  <p>Dict and Code:</p>
  
  <pre><code>Dictionary&lt;AnimName, AnimData&gt; KeyValueData = new Dictionary&lt;AnimName, AnimData&gt;();
  </code></pre>
  
  <p>//This is called once</p>
  
  <pre><code>Start(){
  KeyValueData.Add(AnimName.IDLE, new AnimData(new Vector3(-0.09f, -0.02f, -0.25f), new Vector3(-41.866f, 386.781f, -524.68f), new Vector3(-0.028f, 0.027f, 0.13f), new Vector3(18.724f, 19.477f, -32.435f), 0.3f));
  }
  
  
  void OnGUI()
  {
      if (GUI.Button(new Rect(10, 10, 150, 100), "GET DATA"))
      {
          Debug.Log(KeyValueData [AnimName.IDLE]);
      }
      if (GUI.Button(new Rect(200, 10, 150, 100), "GET DATA CAST"))
      {
          AnimName a = new AnimName("IDLE");
          Debug.Log(KeyValueData [a]);
      }
  
  }
  </code></pre>