36
1
using System;
2
using System.Collections.Generic;
3
4
namespace IDcs
5
{
6
public class Program
7
{
8
public static void Main(string[] args)
9
{
10
HashSet<int> hash = new HashSet<int>();
11
12
hash.Add(51);
13
hash.Add(13);
14
hash.Add(73);
15
hash.Add(7);
16
hash.Add(3);
17
hash.Add(17);
18
Console.WriteLine("HashSet: ");
19
20
foreach (int i in hash)
21
Console.WriteLine(i);
22
Console.WriteLine();
23
Console.WriteLine("Count: " + hash.Count);
24
25
HashSet<int> hash2 = new HashSet<int>();
26
hash2.Add(57);
27
hash2.Add(21);
28
foreach (int i in hash2)
29
Console.WriteLine(i);
30
Console.WriteLine("Apakah value hash2 ada didalam hash 1 ? = " + hash2.IsSubsetOf(hash));
31
hash.Clear();
32
Console.WriteLine("Count: " + hash.Count);
33
}
34
}
35
}
36
Cached Result
HashSet:
51
13
73
7
3
17
Count: 6
57
21
Apakah value hash2 ada didalam hash 1 ? = False
Count: 0
51
13
73
7
3
17
Count: 6
57
21
Apakah value hash2 ada didalam hash 1 ? = False
Count: 0