So,I have three separate lists of integers and I want to convert them in a 2D array. I have tried to concat the 3 lists but it becomes a single array not 2D. I want to take the 1st element of each list and form a 2D array.
var startIndex= new List<int>(){ 0, 0, 0, 0 };
var endIndex= new List<int>(){ 0, 1, 2, 3};
var subs= new List<int>(){ 0, 1, 1, 0 };
var queries = startIndex.Concat(endIndex).Concat(subs).ToArray(); //this doesn't work
I want something like this-
var queries = [[0,0,0],[0,1,1],[0,2,1],[0,3,0]] //taking first element from each list and so on
I didn't find an eaasy way in c#, any help would be appreciated?
I have started to convert the lists to arrays-
var startArr = startIndex.ToArray();
var endArr = endIndex.ToArray();
var subArr = subs.ToArray();
>`. You can easily adapt that to produce a `int[][]`. If you want a `int[,]`, I think you'd have to copy the values by yourself.
– Sweeper May 03 '21 at 02:37