I’d like to populate an arraylist by specifying a list of values just like I would an integer array, but am unsure of how to do so without repeated calls to the ‘add’ method.
For example, I want to assign { 1, 2, 3, ‘string1’, ‘string2’ } to an arraylist. I know for other arrays you can make the assignment like:
int[] IntArray = {1,2,3};
Is there a similar way to do this for an arraylist? I tried the addrange method but the curly brace method doesn’t implement the ICollection interface.
Array list has ctor which accepts ICollection, which is implemented by the Array class.