Check whether an array is a subset of another

后端 未结 10 1075
走了就别回头了
走了就别回头了 2020-11-22 16:17

Any idea on how to check whether that list is a subset of another?

Specifically, I have

List t1 = new List { 1, 3, 5 };
L         


        
10条回答
  •  广开言路
    2020-11-22 16:50

    If you are unit-testing you can also utilize the CollectionAssert.IsSubsetOf method :

    CollectionAssert.IsSubsetOf(subset, superset);
    

    In the above case this would mean:

    CollectionAssert.IsSubsetOf(t2, t1);
    

提交回复
热议问题