How to use HashSet in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
  
class Program
{
    static void Main() {
        HashSet<string> hst = new HashSet<string>();
         
        hst.Add("c#");
        hst.Add("c");
        hst.Add("c#");
        hst.Add("java");
        hst.Add("c#");

        foreach (var item in hst) {
           Console.WriteLine(item);
        }
    }
}
 
  
  
/*
run:
  
c#
c
java

*/

 



answered Dec 13, 2020 by avibootz

Related questions

1 answer 115 views
115 views asked Mar 9, 2023 by avibootz
1 answer 114 views
114 views asked Feb 7, 2024 by avibootz
1 answer 136 views
136 views asked Jul 18, 2022 by avibootz
2 answers 153 views
1 answer 170 views
170 views asked Oct 29, 2019 by avibootz
1 answer 148 views
...