c# - Why Dictionary.Item() throws exception on a key not found while IDictionary.Item() should not? -
c# - Why Dictionary<TKey, TValue>.Item() throws exception on a key not found while IDictionary.Item() should not? -
that's seems unusual me dictionary.item() method throws keynotfoundexception while idictionary.item() not. , dictionary implements interface. why there such implemenation image breaks interface convention?
(also symbol type construction image thought behind dictionary seems have convention method should not throw exception.)
idictionary not generic, illustration hashtable implements it. hashtable's key , it's value objects, hence can (and indeed does) homecoming null if key not found. idictioanary<tkey, tvalue>'s value can value type, hence has no "error"-value null can returned instead.
c# dictionary symbol-table
Comments
Post a Comment