C# remove duplicate dictionary items from List<>? -
so collection of dictionary items in list:
list<dictionary<string, string>> inputdata = new list<dictionary<string, string>>(inputs); list<dictionary<string, string>> itemstack = new list<dictionary<string, string>>();
now want each inputdata dictionary item want check if itemstack has same value (dictionary item) already.
i thinking like?
foreach (var item in inputdata) { if(!itemstack.contains(item){ itemstack.add(item)} else{ //duplicate found} }
it doesn't check items values inside? assumes doesn't have it... want if itemstack contains , item in stack don't include it. know i'm missing obvious. thanks,
dictionary reference type, doesn't check "deep" value expected.
you have write own "contains" method, either totally separate method or extension of dictionary use instead, example:
if(!mycontains(itemstack, item)){ itemstack.add(item)}
Comments
Post a Comment