C# – Populate list from array

arraysc++generics

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);

Best Solution

You could convert the array to a List:

string[] strings = { "hello", "world" };
IList<string> stringList = strings.ToList();