CSharp examples for Collection:List
Initialize a List<string> from a HashSet<string>
using System;//from w w w .j a va2 s .co m using System.Collections.Generic; class Program { static void Main(string[] args) { Console.WriteLine("\nInitialize a List<string> from a HashSet<string>: "); HashSet<string> set = new HashSet<string> { "five", "six", "seven" }; set.Add("eight"); // Adding a non-duplicate succeeds. set.Add("six"); List<string> strList3 = new List<string>(set); Console.WriteLine("Resulting list: "); foreach (string s in strList3) { Console.WriteLine(s); } } }