How to convert HashSet to string in C#

1 Answer

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

class Program
{
    static void Main() {
        HashSet<char> hs = new HashSet<char>();
         
        hs.Add('a');
        hs.Add('b');
        hs.Add('c');

        string s = string.Join("", hs);
        
        Console.Write(s);
    }
}
  
  
  
/*
run:
  
abc
  
*/

 



answered Oct 29, 2019 by avibootz

Related questions

1 answer 263 views
2 answers 370 views
370 views asked Oct 28, 2019 by avibootz
1 answer 206 views
206 views asked Jul 18, 2022 by avibootz
1 answer 211 views
211 views asked Feb 7, 2024 by avibootz
1 answer 217 views
217 views asked Mar 9, 2023 by avibootz
1 answer 235 views
235 views asked Jul 18, 2022 by avibootz
...