I have a strange error in my code...
Code:
public class PropertyCollection<T> : IDictionary<T, string>
{
        private Dictionary<T, string> dict;
        ...
        public string this[T key]
        {
            get
            {
                bool has_key = this.Keys.Any(x => x == key); 
                return this.dict[key];
            }
            set
            {
                this.dict[key] = value;
            }
        }
        ...
}
The first row
bool has_key = this.Keys.Any(x => x == key);
returns true.
But
return this.dict[key];
throws the error:
System.Collections.ListDictionaryInternal.NodeKeyValueCollection: The given key was not present in the dictionary.
How this could be?
If I change the row, that throws an exception, to
return this.dict[this.Keys.First(x => x == key)];  
everything becomes normal and there is now error.
 
     
     
    