I am trying to create a two-position vector, where at each position I add a two-dimensional array of type string
, which leads me to create a two-dimensional array list as follows:
List<String[,]> multi = new List<string[,]>();
then create my two dimensional array and add the values to it 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 array to the list as follows:
multi.Add(m2);
The problem here is that when I want to pass my list to a array
with the toArray()
following method, I get an error:
string[] main = multi.ToArray();
The question is: How can I make that list become a array
?
The problem is in the data type that you assign to main.
When converting multi to Array, what will be returned is an Array of matrices, not an Array of strings: