I have this:
Dictionary<integer, string> dict = new Dictionary<integer, string>();
I want to select all the items in the dictionary that contain the value abc.
Is there an inbuilt function that lets me do this easily?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well it’s reasonably simple with LINQ:
Note that this won’t be even slightly efficient – it’s an
O(N)operation, as it needs to check every entry.If you need to do this frequently, you may want to consider using another data structure –
Dictionary<,>is specifically designed for fast lookups by key.