In C # you can do the following:
List<int> registers = new List<int> { 1, 2, 3, 4 };
This will create a list with 1, 2, 3 and 4 in the list. Suppose I was given a list from some function, and I want to insert a bunch of numbers, as shown below:
List<int> register = somewhere();
register.Add(1);
register.Add(2);
register.Add(3);
register.Add(4);
Is there a cleaner way to do this, as the snippet above?
source
share