C# massive insertion into data structures

Posted by Seabass on Stack Overflow See other posts from Stack Overflow or by Seabass
Published on 2010-04-28T06:18:59Z Indexed on 2010/04/28 6:23 UTC
Read the original article Hit count: 147

Filed under:

In C#, you can do the following:

List registers = new List { 1, 2, 3, 4 };

This will produce a list with 1, 2, 3, and 4 in the list. Suppose that I am given a list from some function and I want to insert a bunch of numbers like the following:

List register = somewhere(); register.Add(1); register.Add(2); register.Add(3); register.Add(4);

Is there a cleaner way of doing this like the snippet above?

© Stack Overflow or respective owner

Related posts about c#