List of multidimensional arrays in c #

1

I am trying to create a vector of two positions, where in each position I add a two-dimensional matrix of type string , which led me to create a list of two-dimensional arrays as follows:

List<String[,]> multi = new List<string[,]>();

Then create my bidimensional matrix and add the values as follows just as an example:

string[,] m2 = new string[2, 2];

m2[0, 0] = "jose";
m2[0, 1] = "juan";
m2[1, 0] = "luis";
m2[1, 1] = "pedro";

then add that matrix to the list as follows:

multi.Add(m2);

The problem here is that when I want to pass my list to array with the toArray() method in the following way, it marks me error:

string[] main = multi.ToArray();

The question is: How can I make it so that this list becomes a array ?

    
asked by José Gregorio Calderón 10.05.2016 в 09:52
source

1 answer

3

The problem is in the type of data you assign to main.

When converting multi to Array, what is going to return is an Array of arrays, not an Array of strings:

string[][,] main = multi.ToArray();
    
answered by 10.05.2016 / 10:00
source