using System.Collections.Generic; public class MyApplication { public static void Main(string[] args) { var x = new List<string>(){"Mohan", "Kriti", "Salim"}; var y = new List<string>(x); foreach (var data in y) { System.Console.WriteLine(data); } } }
So, in the above code we have created a List and initialised to the variable x.
var x = new List<string>(){"Mohan", "Kriti", "Salim"};
Below is how the values are positioned in the List,
Then we have created a new List and and passed the List x as parameter.
var y = new List<string>(x);
And the new List y gets all the values of the List x.
And we get the below output,