How to check if a set is a subset of another set in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;

public class Program
{
	public static void Main(string[] args)
	{
		ISet<int> set1 = new HashSet<int>() {1, 2, 3, 4, 5, 6};

		ISet<int> set2 = new HashSet<int>() {2, 4};

		bool result = set2.IsSubsetOf(set1);
	
		Console.WriteLine(result);
	}
}




/*
run:
     
True
 
*/

 



answered Aug 10, 2022 by avibootz
edited Aug 10, 2022 by avibootz

Related questions

1 answer 121 views
1 answer 142 views
1 answer 141 views
1 answer 113 views
1 answer 163 views
...