Hot to avoid exception if we are adding items into Dictionary?

 Posted by Rajesh_Kumar on 1/17/2014 | Category: ASP.NET Interview questions | Views: 700 | Points: 40
Answer:

Always check ContainsKey method of Dictionary to avoid exceptions.

If (Not dict.ContainsKey(Key)) Then

dict.Add(Key,Value)
End If


It checks whether key is there in a dictionary or not.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response