开发者

Duplicates in a dictionary then delete or add record

开发者 https://www.devze.com 2023-01-07 19:04 出处:网络
So I created a dictionary DICTIONARY1 dicFilesDT.Add(dateParts[1], (dateParts[1] + dateParts[2] )); so that I would have just the:

So I created a dictionary DICTIONARY1

dicFilesDT.Add(dateParts[1], (dateParts[1] + dateParts[2] ));

so that I would have just the:

KEY as the Date and VALUE as the Date+Time

I need help in making another dictionary (DICTIONARY2) that would

  1. If there are no Duplicates from checking DICTIONARY2 using foreach keyvaluepair in DICTIONARY1 add Key Pair to DICTIONARY2

  2. Check for duplicates of the Key (Date) (thinking ex. dictionary.ContainsKey)

if the dictionary has the KEY then Compare the KEY VALUE from DICTIONARY 1 to DICTIONARY 2 to see which one is larger

ex. 230132 compared to 100425

if DICTIONARY1 KEY VALUE is larger Delete KeyValuePair from DICTIONARY 2 and add DICTIONARY 1 KEY VALUE

else do nothing and continue the l开发者_如何转开发oop

Thank you folks for helping me wiht this.


You can't have duplicates in a system.collections.generic.dictionary, it will throw an exception if you try to add a duplicate key.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号