C # determines that a set is a subset of another set,
There are two sets:
String [] bigArr = new string [] {"a", "B", "c "};
String [] smallArr = new string [] {"a", "B "};
Now we need to determine whether smallArr is a subset of bigArr. If bigArray and smallArr are used to compare and evaluate the difference set, if the number of difference sets is greater than 0, smallArr is a subset of bigArr.
// Based on the large set, obtain the var variance Tarr = bigArr of the big set based on the small set. t (smallArr); // judge whether it is a subset if (exceptArr. any () {Console. writeLine ("samllArr is a subset of bigArr");} else {Console. writeLine ("samllArr is not a subset of bigArr ");}
In the preceding method, you can only determine whether it is a subset, that is, the set element of the subset is always smaller than the large one.
Sometimes, there is a need to determine whether bigArr contains smallArr, that is, smallArr can be a subset of bigArr, or it can be the same as bigArr.
// Determine whether it is a subset or two 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 ");}