These two methods are guaranteed to return the same value of true/ false.
According to the reference implementation , dict.Keys.Contains(key)delegates dict.ContainsKey(key):
bool ICollection<TKey>.Contains(TKey item){
return dictionary.ContainsKey(item);
}
This method is part of the class KeyCollection. Its field dictionaryrefers to the object dictionaryto which KeyCollectionit returned the property Keys.
source
share