c# - ConcurrentDictionary AddOrUpdate a list -


i'm trying use concurrentdictionary filtering task.

if number appears in list, want copy entry 1 dictionary another.

but part of addorupdate not right - v.add(number)

i

"cannot implicitly convert type 'void' 'system.collections.generic.list'

and 2 more errors.

class program {     static void main(string[] args)     {         program p = new program();         list<int> filter = new list<int> {1,2};         p.filter(filter);     }       private void filter(list<int> filter)     {         dictionary<string, list<int>> unfilteredresults = new dictionary<string, list<int>>();         unfilteredresults.add("key1", new list<int> { 1,2,3,4,5});          concurrentdictionary<string, list<int>> filteredresults = new concurrentdictionary<string, list<int>>();          foreach (keyvaluepair<string, list<int>> unfilteredresult in unfilteredresults)         {             foreach (int number in unfilteredresult.value)             {                 if (filter.contains(number))                 {                     filteredresults.addorupdate(unfilteredresult.key, new list<int> { number }, (k, v) => v.add(number));                 }             }         }     } } 

thanks lucas trzesniewski, pointing out mistake in comments - didn't want post answer.

you mean: (k, v) => { v.add(number); return v; }


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -