【发布时间】:2012-07-23 14:41:34
【问题描述】:
我想将数组添加到列表或多维数组(不是一次全部...)。但我真的不明白为什么这会这么难。
假设我有这个:
string[] a = { "h", "b"};
string[] b = { "c", "a", "i" };
string[] c = { "out", "in", "file", "test" };
ArrayList x = null;
x.Add(a); //error: Object reference not set to an instance of an object.
x.Add(b);
x.Add(c);
我可以用 ArrayList 代替吗
string[,] x = null;
但是没有.Add的选项
假设我有未知数量的大小未知的字符串 [] - 如何将它们添加到列表/多维数组中?再说一遍:我想一一添加这些字符串[]。有什么想法吗?
【问题讨论】:
-
只是想知道,这是什么
ArrayList x = null;? -
错误“对象引用未设置为对象的实例”,以供将来参考,意味着您忘记初始化对象。
标签: c# .net arrays string list