且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查两个列表是否具有相同的项目

更新时间:2023-11-25 17:30:52

这就是设置的内容(例如, SetEquals 验证集合和另一个集合是否包含相同的元素.

That's what sets (e.g., HashSet<T>) are for. Sets have no defined order, and SetEquals verifies whether the set and another collection contain the same elements.

var set = new HashSet<int>(list1);
var equals = set.SetEquals(list2);