How to check whether Dictionary contains any value or not?

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

With the help of ContainsValue method,we can check whether dictionary has a value or not?


Dictionary<string, string> dict_names = new Dictionary<string, string>();
dict_names.Add("name", "rajesh");

If(dict_names.ContainsValue["rajesh"])
return true;
else
return false;


It will return true because rajesh is present inside dictionary.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response