Problem with IDictionary<Complex Key, Complex Value>.Remove() implementation
<p>Hi I don't understand why this code doesn't work - it don't remove key; I still get "2" on output.</p>

<pre><code>Bencode.BencodeDict d = new myTorrent.Bencode.BencodeDict();
d.Dict.Add(new Bencode.BencodeString("info"), new Bencode.BencodeString("1"));
d.Dict.Add(new Bencode.BencodeString("info2"), new Bencode.BencodeString("2"));
d.Dict.Add(new Bencode.BencodeString("info3"), new Bencode.BencodeString("3"));

d.Remove(new Bencode.BencodeString("info2"));
Bencode.BencodeVariable s1;
s1 = d[new Bencode.BencodeString("info2")];
if (s1 != null)
   Console.WriteLine(System.Text.UTF8Encoding.UTF8.GetString(s1.Encode()));
</code></pre>

<p>My BencodeDict and BencodeString</p>

<pre><code>namespace myTorrent.Bencode
{
   class BencodeDict : BencodeVariable, IDictionary&lt;BencodeString, BencodeVariable&gt;
   {
      private Dictionary&lt;BencodeString, BencodeVariable&gt; dict;

      public BencodeDict() {
         this.dict = new Dictionary&lt;BencodeString,BencodeVariable&gt;();
      }

      protected override void InternalDecode(BinaryReader data) { /*...*/ }
      public override long ByteLength() { /*...*/ }    
      public override byte[] Encode() { /*...*/ }

      //#region Overridden Methods
        public override bool Equals(object ob)
        {
            if (ob == null)
               return false;

            BencodeDict y = ob as BencodeDict;
            if (this.dict.Count != y.dict.Count)
                return false;

            BencodeVariable val;
            foreach (KeyValuePair&lt;BencodeString, BencodeVariable&gt; keypair in this.dict)
            {
                if (!y.TryGetValue(keypair.Key, out val))
                    return false;

                if (!keypair.Value.Equals(val))
                    return false;
            }

            return true;
        }

        public override int GetHashCode()
        {
            int result = 0;
            foreach (KeyValuePair&lt;BencodeString, BencodeVariable&gt; keypair in this.dict)
            {
                result ^= keypair.Key.GetHashCode();
                result ^= keypair.Value.GetHashCode();
            }
            return result;
        }

        #region IDictionary and IList methods
        public void Add(BencodeString key, BencodeVariable value)
        {
            this.dict.Add(key, value);
        }

        public void Add(KeyValuePair&lt;BencodeString, BencodeVariable&gt; item)
        {
            this.dict.Add(item.Key, item.Value);
        }
        public void Clear()
        {
            this.dict.Clear();
        }

        public bool Contains(KeyValuePair&lt;BencodeString, BencodeVariable&gt; item)
        {  
            if (!this.dict.ContainsKey(item.Key))
                return false;

            return this.dict[item.Key].Equals(item.Value);
        }

        public bool ContainsKey(BencodeString key)
        {
            foreach(KeyValuePair&lt;BencodeString, BencodeVariable&gt; pair in this.dict) {
               if (pair.Key.Equals(key))
                  return true;
            }
            return false;
        }

        public void CopyTo(KeyValuePair&lt;BencodeString, BencodeVariable&gt;[] array, int arrayIndex) { /*...*/ }
        public int Count
        {
            get { return this.dict.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(BencodeString key)
        {

            return this.dict.Remove(key);
        }

        public bool Remove(KeyValuePair&lt;BencodeString, BencodeVariable&gt; item)
        {
            return this.dict.Remove(item.Key);
        }

        public bool TryGetValue(BencodeString key, out BencodeVariable value)
        {
           foreach(KeyValuePair&lt;BencodeString, BencodeVariable&gt; pair in this.dict)
              if ( pair.Key.Equals(key) ) {
                 value = pair.Value;
                 return true;
              }
           value = null;
           return false;
        }

        public BencodeVariable this[BencodeString key]
        {  
            get {
                foreach(KeyValuePair&lt;BencodeString, BencodeVariable&gt; pair in this.dict)
                     if ( pair.Key.Equals(key) )
                     return pair.Value;
                return null;
            }
            set { this.dict[key] = value; }
        }

        public ICollection&lt;BencodeString&gt; Keys
        {
            get { return this.dict.Keys; }
        }

        public ICollection&lt;BencodeVariable&gt; Values
        {
            get { return this.dict.Values; }
        }

        public IEnumerator&lt;KeyValuePair&lt;BencodeString, BencodeVariable&gt;&gt; GetEnumerator()
        {
            return this.dict.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.dict.GetEnumerator();
        }
        #endregion
   }
}


   class BencodeString : BencodeVariable
      {
         private byte[] str;

         public BencodeString() {
            this.str = null;
         }

         public BencodeString(string str) {
            this.str = encoding.GetBytes(str);
         }

         public override bool Equals(object ob)
         {
            if (ob == null)
               return false;

            BencodeString y = ob as BencodeString;

            return (encoding.GetString(this.str) == encoding.GetString(y.str));
         }

         public override int GetHashCode()
         {

            return this.str.GetHashCode();
         }
      }
</code></pre>
