I have string array say string str[] = {"a", "b"}
and List<string> lst = new List<string> {"a", "b"}
How can I make sure that both string array and list contains the same values. Note: The values can be in any order but must have the same frequency.
Can anyone tell me how to do it in LINQ?
Thanks.
Maybe I'm missing something, but why don't you just
SequenceEqual()
¹Saves the dictionary approach of Jason (which, obviously, should work as well) and seems more natural/easy to me?
①: https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.sequenceequal
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