Difference in HybridDictionary and Generic Dictionary Item behavior if the specified key is not found

In .Net 1.1 I've used HybridDictionary.Item and my code expected that if the specified key is not found, attempting to get it returns a null reference.
But in .Net 2.0  Generic Dictionary.Item  if the specified key is not found, a get operation throws a KeyNotFoundException  and I have to use Dictionary.TryGetValue  or check ContainsKey before calling Item.

 

posted @ Wednesday, August 16, 2006 11:38 AM

Print

Comments on this entry:

# re: Difference in HybridDictionary and Generic Dictionary Item behavior if the specified key is not found

Left by Michael Freidgeim at 6/11/2007 11:57 AM
Gravatar
Se also more details in Frans Bouma's blog "Dictionary<TKey, TValue> vs. Hashtable() tip" http://weblogs.asp.net/fbouma/archive/2005/12/12/432942.aspx

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345