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 218 views
218 views asked Mar 9, 2023 by avibootz
1 answer 219 views
219 views asked Feb 7, 2024 by avibootz
1 answer 238 views
238 views asked Jul 18, 2022 by avibootz
2 answers 296 views
1 answer 255 views
255 views asked Oct 29, 2019 by avibootz
1 answer 265 views
...