我想使用2-D阵列但我不能提前知道它的大小.所以我的问题是:如何申报?然后如何在其中添加值?
String[,] tabConfig = new String[?, 4];
foreach(blabla with i)
{
tabConfig[i, 0] = a;
tabConfig[i, 1] = b;
tabConfig[i, 2] = c;
tabConfig[i, 3] = d;
}
Run Code Online (Sandbox Code Playgroud)
我知道我也可以使用列表,但我不是很熟悉它.
谢谢!
编辑:支持你自己!在Jon Skeet的帮助下,我的真实代码来了!
List<string[]> tabConfig = new List<string[]>();
String[] temp = new String[4];//The array that will be inside the List
int line = 0, column = 0;
foreach (XmlNode e in doc.DocumentElement.ChildNodes)
{
if (e.Attributes["Server"].Value == choice)
{
temp[0] = e.Attributes["Serveur"].Value;//Here is value 'a'
column = 1;
foreach (XmlNode i in …Run Code Online (Sandbox Code Playgroud)