Pro EP 31 : SequenceEqual Method in LINQ for Lists Comparison
♉ This method is used to check whether two sequences are equal or not and it returns true/false. If two sequence have same elements in same order and same values those are considered equal according this method.
♉ It has an overload method as well that takes 𝙸𝙴𝚚𝚞𝚊𝚕𝚒𝚝𝚢𝙲𝚘𝚖𝚙𝚊𝚛𝚎𝚛 that allows us to provide a comparer of our own choice if we don’t want to use by default.
♉ Default comparer is case sensitive, to make it case-insensitive we can pass 𝚂𝚝𝚛𝚒𝚗𝚐𝙲𝚘𝚖𝚙𝚊𝚛𝚎𝚛.𝙾𝚛𝚍𝚒𝚗𝚊𝚕𝙸𝚐𝚗𝚘𝚛𝚎𝙲𝚊𝚜𝚎 in overloaded method.
♉ If sequence are complex by default their reference is compared instead of values , to compare values we have to provide our custom comparer.
We need to add a custom comparer.
Now we can use it to compare complex lists
♉If we want to compare two sequence that are not in same order we need to first order them ascend/descend and then perform comparison
If you want to help the author in growing
- Subscribe my Weekly .NET Newsletter of C#/.NET with 800+ Software Engineers.
- Become Patron to get access to 90+ Compiled Questions and Answers at one place.
- Download my eBook at Gum road that contains 30+ .NET Tips.