c# - How can I check for string values in a Dictionary<string, List<string[]>>() object? -
to keep simple, have following dictionary fill unknown amount of strings every string key. have following list of strings.
var dict = new dictionary<string, list<string[]>>(); ilist<string> headerlist = new list<string>(); how can check if string list value in dictionary? data looks similar this:
key value ----- ------------------ car honda, volks, benz truck chevy, ford i need check if "honda", example, contained int dictionary values. thinking need following see if values contain list, contain string in question. keep in mind new c#.
foreach (string header in headerlist) { // wrong, don't know put in if statement if (dict.containsvalue(r => r.contains(header))) { // stuff } }
john odom correct, need list.
what suggest use hashset<string> internally value of diictionary. e.g. dictionary<string, hashset<string>>
then when comes querying can this:
headerlist.where(x => dict.values.any(d => d.contains(x))).tolist() have @ .net nested loops vs hash lookups performance comparison
Comments
Post a Comment