/// <summary> /// Gets and sets the value with the specified key. /// ArgumentException is thrown if the key does not already exist in the hash table /// </summary> /// <param name="key">The key of the value to retrieve</param> /// <value>The value associated with the specified key</value> public TValue this[TKey key] { get { TValue value; if (_array.TryGetValue(key, out value)) { throw new ArgumentException("key"); } return(value); } set{ _array.Update(key, value); } }
//for HashTable[Key] //and HashTable[Key] = Value public TValue this[TKey key] { get { //trygetvalue needs a out value because it returns a bool TValue value; //if it finds and returns true, return the value, if not, throw exception // hmmmmmmmmm on the exception thrown. safety? if (!_arrayClass.TryGetValue(key, out value)) { throw new ArgumentException("key"); } return(value); } set { //call update with key (input) //because it is set, it automatically grabs whatever is on right side of equals (=) and using that as value _arrayClass.Update(key, value); } }