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 158 views
2 answers 250 views
250 views asked Oct 28, 2019 by avibootz
1 answer 138 views
138 views asked Jul 18, 2022 by avibootz
1 answer 123 views
123 views asked Feb 7, 2024 by avibootz
1 answer 126 views
126 views asked Mar 9, 2023 by avibootz
1 answer 148 views
148 views asked Jul 18, 2022 by avibootz
...