C#: how do you check lists are the same size & same elements?

后端 未结 6 1406
一整个雨季
一整个雨季 2021-02-06 12:18

There are two lists of string

List A;
List B;

What is the shortest code you would suggest to check that A.Count ==

6条回答
  •  长情又很酷
    2021-02-06 12:53

    A.Count == B.Count && new HashSet(A).SetEquals(B);
    

    If different frequencies of duplicates are an issue, check out this question.

提交回复
热议问题