I'm new to C# and need some help with comparing collections. I have two List<string>
collections with their contents as below:
Collection Old: {"AAA","BBB","CCC"}
Collection New: {"BBB","CCC","DDD"}
I want to get a collection like below:
Collection Final: {"AAA", "Remove"; "BBB", "Keep"; "CCC", "Keep"; "DDD", "Add"}
How can I do this?
old.Except(new) will give you those items to remove
new.Except(old) will give you items to add
old.Intersect(new) will give you items to keep
(This is assuming you don't mind using the System.Linq namespace)
Or if you prefer, you can consider each item individually and check the existence in each list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With