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 265 views
2 answers 373 views
373 views asked Oct 28, 2019 by avibootz
1 answer 208 views
208 views asked Jul 18, 2022 by avibootz
1 answer 219 views
219 views asked Feb 7, 2024 by avibootz
1 answer 218 views
218 views asked Mar 9, 2023 by avibootz
1 answer 237 views
237 views asked Jul 18, 2022 by avibootz
...