Is there a way to define a List<> of two elements string array?
- by Alexander Prokofyev
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?