What is the equivalent of Python set(string) in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
 
internal class Program
{
    public static HashSet<char> makeset(string str) {
        char[] arr = str.ToCharArray();
         
        var hset = new HashSet<char>(arr);

        return hset;
    }
     
    public static void Main(string[] args)
    {
        string str = "CSharp Programming";
 
        Console.WriteLine(string.Join(",", makeset(str)));   
    }
}
 
 
 
 
/*
run:
  
C,S,h,a,r,p, ,P,o,g,m,i,n
  
*/

 



answered Feb 7, 2024 by avibootz
edited Feb 7, 2024 by avibootz

Related questions

1 answer 118 views
1 answer 101 views
1 answer 147 views
1 answer 197 views
1 answer 148 views
1 answer 150 views
1 answer 141 views
...