c# add list into hashset
C#[Edit]
+
0
-
0
c# add List into HashSet
1 2 3List<string> letters = new List<string> { "A", "B", "C" }; HashSet<string> alphabet = new HashSet<string>(letters);
[Edit]
+
0
-
0
c# add List into HashSet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20using System; using System.Collections.Generic; public class Program { public static void Main() { List<string> letters = new List<string> { "A", "B", "C" }; HashSet<string> alphabet = new HashSet<string>(letters); foreach (string letter in alphabet) Console.WriteLine(letter); } } // Output: // A // B // C
[Edit]
+
0
-
0
c# add List into HashSet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22using System; using System.Collections.Generic; public class Program { public static void Main() { List<string> letters = new List<string> { "A", "B", "C" }; HashSet<string> alphabet = new HashSet<string>(); alphabet.UnionWith(letters); foreach (string letter in alphabet) Console.WriteLine(letter); } } // Output: // A // B // C