c# - join two dictionary values based on key and check condition on value field -
how merge 2 dictionay dictionary structure
first dictionary:
key: key1 value: {100,name1,address1, address2, address3, address4, address5} {100,name2,address1, address2, address3, address4, address5}
second dictionary:
key: key1 value: {100,name1,field1, field2, field3, field4, field5} {101,name1,field1, field2, field3, field4, field5}
here have check value field list of string array. in above case in both dictionary have common value 100 , name1 so.
expected result:
key: key1 value: {100,name1,address1, address2, address3, address4, address5,field1, field2, field3, field4, field5}
hi below approach. var final = new dictionary>();
foreach (var item in _record1) { var key = item.key;
list<string[]> first = _record1[key]; list<string[]> second = _record2[key]; foreach (var in first) { foreach (var b in second) { if (a[0] == b[0] && a[1] == b[1]) { // operation // add items final } } } }
i able desired result looking approach.
Comments
Post a Comment