I would like to compare two collections (in C#), but I\'m not sure of the best way to implement this efficiently.
I\'ve read the other thread about Enumerable.Sequen
This simple solution forces the IEnumerable's generic type to implement IComparable. Because of OrderBy's definition.
If you don't want to make such an assumption but still want use this solution, you can use the following piece of code :
bool equal = collection1.OrderBy(i => i?.GetHashCode())
.SequenceEqual(collection2.OrderBy(i => i?.GetHashCode()));