There are two of these collections:
string[] Bigarr = new string[] {"A", "B", "C"};
string[] Smallarr = new string[] {"A", "B"};
Now you need to determine if Smallarr is a subset of Bigarr. As long as holding the Bigarray and Smallarr comparison, the difference set, if the number of difference set is greater than 0, it means that Smallarr is a subset of Bigarr.
//On the basis of large sets, the difference sets of large sets are obtained according to the small set varExceptarr =bigarr.except (Smallarr); //determine if it is a subset if(Exceptarr.any ()) {Console.WriteLine ("Samllarr is a subset of the Bigarr"); } Else{Console.WriteLine ("Samllarr is not a subset of Bigarr"); }
In this way, you can only judge if it is a subset, that is, a subset of the set element that is always smaller than the large one.
Sometimes, there is the need to determine whether Bigarr contains Smallarr, that is, Smallarr can be a subset of Bigarr, or it can be the same as Bigarr.
// determines whether a subset or 2 sets are the same if (Smallarr.all (t = bigarr.any (b = b==t))) { Console.WriteLine ("Samllarr is a subset or the same as Bigarr ") ; } Else { Console.WriteLine ("Samllarr is not a subset or the same as Bigarr "); }
C # determines that a collection is a subset of another collection