2 ms·
Yes, for the indexer scenario dict[key] that is an exceptional failure (equivalent to indexing list[index] wher index >= length). The method to get the value of
by alkonaut 7y ago
Yes, for the indexer scenario dict[key] that is an exceptional failure (equivalent to indexing list[index] wher index >= length). The method to get the value of a key only if the key is in the dictionary is TryGet...
I think this design is the best one. It lets you have the program blow up quickly in all cases where the presence of the key is a requirement for the program to be in a valid state (which is common). Otherwise you'd be doing
x = dict[key]
if (x == null)
throw("Unexpected this is. And unfortunate");