protected virtual bool SetEntry(TKey key, TValue value) { var keyExists = KeyedEntryCollection.Contains(key); // if identical key/value pair already exists, nothing to do if (keyExists && value.Equals((TValue)KeyedEntryCollection[key].Value)) { return(false); } // otherwise, remove the existing entry if (keyExists) { KeyedEntryCollection.Remove(key); } // add the new entry KeyedEntryCollection.Add(new DictionaryEntry(key, value)); return(true); }
protected virtual bool AddEntry(TKey key, TValue value) { KeyedEntryCollection.Add(new DictionaryEntry(key, value)); return(true); }