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 120 views
120 views asked Oct 28, 2019 by avibootz
2 answers 238 views
238 views asked Oct 28, 2019 by avibootz
1 answer 170 views
170 views asked Oct 29, 2019 by avibootz
2 answers 152 views
1 answer 125 views
125 views asked Jul 18, 2022 by avibootz
1 answer 114 views
114 views asked Feb 7, 2024 by avibootz
1 answer 115 views
115 views asked Mar 9, 2023 by avibootz
...