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)


 
 
 
Please add 1 and 1 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910