"the given key was not present in the dictionary" error when using a self-defined class as key
<p>I've got code like this:</p>

<pre><code>if (CounterForEachRelatedTagDict.Select(x =&gt; x.Key).Contains(tag.Key))
   CounterForEachRelatedTagDict[tag.Key] += tag.Value;
</code></pre>

<p>Is it possible that the IF statement returns true, at the same time <code>CounterForEachRelatedTagDict[tag.Key]</code> returns "the given key was not present in the dictionary" error? <code>tag</code> is a <code>KeyValuePair&lt;MyClass,int&gt;</code>.</p>

<p><code>CounterForEachRelatedTagDict</code> is initiated like this:</p>

<pre><code>Dictionary&lt;MyClass, int&gt; CounterForEachRelatedTagDict = new Dictionary&lt;MyType, int&gt;();
</code></pre>

<p><code>MyClass</code> is like this</p>

<pre><code>public class MyClass
{
    public string name {get;set;}
    public Guid Id { get; set; }
    ...
}
</code></pre>

<p>It seems almost unreasonable to me...</p>
