Is there a way to define a List<> of two elements string array?

Posted by Alexander Prokofyev on Stack Overflow See other posts from Stack Overflow or by Alexander Prokofyev
Published on 2008-11-13T07:00:59Z Indexed on 2012/09/30 15:38 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

I want to build two-dimentional array of strings where length of one dimention is 2. Similar to this

string[,] array = new string[,]
{
    {"a", "b"},
    {"c", "d"},
    {"e", "f"},
    {"g", "h"}
}

Doing

List<string[]> list = new List<string[]>();

list.Add(new string[2] {"a", "b"});
list.Add(new string[2] {"c", "d"});
list.Add(new string[2] {"e", "f"});
list.Add(new string[2] {"g", "h"});

list.ToArray();

gives me

string[][]

but not

string[,] 

array.

Just curious, is there some trick to build dynamically

string[,] 

array somehow?

© Stack Overflow or respective owner

Related posts about c#

Related posts about arrays