C# code to create a List and initialize to another list then adding the new item in List

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 1506
C# code to create a List and initialize to another list then adding the new item in List
var dnfLst_1 = new List<int>() { 90, 70, 30, 10, 60, 50, 40 };
var dnfLst_2 = new List<int>(dnfLst_1);

dnfLst_2.Add(80);


Result
dnfLst_2 90, 70, 30, 10, 60, 50, 40, 80

Comments or Responses

Login to post response