if i have an array. can i populate a generic list from that array:
Foo[] fooList . . . (assume populated array)
// This doesn't seem to work
List<Foo> newList = new List<Foo>(fooList);
Array.fill For example, if we want to set up an array with ten slots and populate it with the string “hello” we'd write some code like this: let filledArray = new Array(10). fill('hello'); This method works great for immutable values like numbers, strings, and booleans.
ArrayList of arrays can be created just like any other objects using ArrayList constructor.
You could convert the array to a List:
string[] strings = { "hello", "world" };
IList<string> stringList = strings.ToList();
You are looking for List(t).AddRange Method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With