How to convert (add) array of strings to HashSet in C#

1 Answer

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

class Program
{
    static void Main() {
        string[] arr = {"c#", "php", "java"};

        var hs = new HashSet<string>(arr);

        foreach (string item in hs) {
            Console.Write("{0}{1}", item, " ");
        }
    }
}



/*
run:

c# php java 

*/

 



answered Oct 28, 2019 by avibootz

Related questions

1 answer 221 views
221 views asked Oct 28, 2019 by avibootz
2 answers 373 views
373 views asked Oct 28, 2019 by avibootz
1 answer 255 views
255 views asked Oct 29, 2019 by avibootz
2 answers 296 views
1 answer 208 views
208 views asked Jul 18, 2022 by avibootz
1 answer 227 views
227 views asked Jul 23, 2023 by avibootz
1 answer 199 views
199 views asked Jul 22, 2023 by avibootz
...