I have two lists as below, how can I say that they have the same elements. The order is not important.
var list1 = new List {1,2,3}; var list2 = n
That's what sets (e.g., HashSet) are for. Sets have no defined order, and SetEquals verifies whether the set and another collection contain the same elements.
var set = new HashSet(list1); var equals = set.SetEquals(list2);