有如下语句,本意是想如果strArray4数组的值不等于"无说明",就将它的值依次合并然后赋值给BZDemo数组:
string[] BZDemo = null;
for (int j = 0; j < table.Rows.Count; j++)
{
strArray4 = table.Rows[j]["los"].Split(base.sDefaultSplit.ToCharArray());
for (int x = 0; x < 5; x++)
{
String tempbz=strArray4[x];
if (tempbz != "无说明")
{
BZDemo[x] = BZDemo[x].ToString() + tempbz;
}
else
{
BZDemo[x] = BZDemo[x];
}
}
}但运行时显示”未将对象引用设置到对象的实例“,
将BZDemo[x] = BZDemo[x].ToString() + tempbz;
BZDemo[x] = BZDemo[x];
这两句屏蔽后可正常运行,请问这两句有什么问题吗?该如何解决呀?多谢了
string[] BZDemo = null;
for (int j = 0; j < table.Rows.Count; j++)
{
strArray4 = table.Rows[j]["los"].Split(base.sDefaultSplit.ToCharArray());
for (int x = 0; x < 5; x++)
{
String tempbz=strArray4[x];
if (tempbz != "无说明")
{
BZDemo[x] = BZDemo[x].ToString() + tempbz;
}
else
{
BZDemo[x] = BZDemo[x];
}
}
}但运行时显示”未将对象引用设置到对象的实例“,
将BZDemo[x] = BZDemo[x].ToString() + tempbz;
BZDemo[x] = BZDemo[x];
这两句屏蔽后可正常运行,请问这两句有什么问题吗?该如何解决呀?多谢了
你声明后没有实例化啊
new一下就好了