c# add list into hashset

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 22
using 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