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

后端 未结 6 1504
一整个雨季
一整个雨季 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:49

    If you call Enumerable.Except() on the two lists, that will return an IEnumerable containing all of the elements that are in one list but not the other. If the count of this is 0, then you know that the two lists are the same.

提交回复
热议问题