How to clear dictionary items?

 Posted by Rajesh_Kumar on 1/16/2014 | Category: C# Interview questions | Views: 625 | Points: 40
Answer:

Clear() method is used for removing all items from dictionary.

Dictionary<int,string> dict_names = new Dictionary<int,string>();

dict_names.Add("n]ame","rajesh");
dict_names.Add("surname","sathua");
//count = 2

dict_names.Clear();
//count = 0


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response