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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -