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);
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);
You could convert the array to a List:
string[] strings = { "hello", "world" };
IList<string> stringList = strings.ToList();
As @korki said, AddRange will work, but the code you've posted should work fine. For example, this compiles:
var i = new int[10];
var list = new List<int>(i);
Could you show us more of your code?