How to convert list of objects with two fields to array with one of them using LINQ
c#, linq
Solution
You were almost there:
int[] array = list.Select(obj=>obj.a).ToArray();
you need to just add `ToArray` at the end
Problem
It's hard for me to explain, so let me show it with pseudo code: ``` ObjectX { int a; string b; } List<ObjectX> list = //some list of objectsX// int [] array = list.Select(obj=>obj.a); ``` I want to fill an array of ints with ints from objectsX, using only one line of linq.