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.

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
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:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910