/// <summary> /// Adds the key/value pair to the node. If the key already exists in the /// list an ArgumentException will be thrown /// </summary> /// <param name="key">The key of the item being added</param> /// <param name="value">The value of the item being added</param> public void Add(TKey key, TValue value) { // lazy init the linked list if (_items == null) { _items = new LinkedList <HashTableNodePair <TKey, TValue> >(); } else { // Multiple items might collide and exist in this list - but each // key should only be in the list once. foreach (HashTableNodePair <TKey, TValue> pair in _items) { if (pair.Key.Equals(key)) { throw new ArgumentException("The collection already contains the key"); } } } // if we made it this far - add the item _items.AddHead(new HashTableNodePair <TKey, TValue>(key, value)); }