I would use join
to find the matches:
Dictionary<int, string> dict = new Dictionary<int, string>
{
{1, "A"},
{2, "B"},
{3, "c"},
{4, "D"},
{5, "E"},
};
string[] values = new [] {"A","D","E"};
var query =
from kvp in dict
join s in values on kvp.Value equals s
select new {kvp.Key, Found = true};
You could also use where values.Contains(kvp.Value)
instead of a join, but that will search the array each time, while the join will create lookups which will be searched more efficiently. For the size of the data you posted, there probably isn’t much performance gain, but for large collections it could be significantly faster.
solved Array with Dictionary in c# using Linq [closed]