C# NullException:值不能未定义。参数名称:源 //获取条目 string[,]entries=搜索(replacebankwithany( 新字符串[]{name,code,supplier,lot,grams,date,shelf,inStock,costKG}), 数据); int length=entries.GetLength(0); int x=0; if(entries.GetLength(1)!=0) { x=0; //填充表 //对于(uint x=0;x
我尝试使用for(代码中有注释),然后使用了一段时间,但它们都在标题中返回了错误。我将变量x移到if之外,但它仍然不起作用。我确信条目不为NULL,这既是因为if(ENTRIES.GetLength(1)!=0)为true,也是因为我在调试器中检查了它。非常感谢您的回复 问题在(xC# NullException:值不能未定义。参数名称:源 //获取条目 string[,]entries=搜索(replacebankwithany( 新字符串[]{name,code,supplier,lot,grams,date,shelf,inStock,costKG}), 数据); int length=entries.GetLength(0); int x=0; if(entries.GetLength(1)!=0) { x=0; //填充表 //对于(uint x=0;x,c#,winforms,for-loop,while-loop,null,C#,Winforms,For Loop,While Loop,Null,我尝试使用for(代码中有注释),然后使用了一段时间,但它们都在标题中返回了错误。我将变量x移到if之外,但它仍然不起作用。我确信条目不为NULL,这既是因为if(ENTRIES.GetLength(1)!=0)为true,也是因为我在调试器中检查了它。非常感谢您的回复 问题在(x
//get entries
string[,] entries = Search(ReplaceBlankWithAny(
new string[] { name, code, supplier, lot, grams, date, shelf, inStock, costKG }),
data);
int length = entries.GetLength(0);
int x = 0;
if (entries.GetLength(1) != 0)
{
x = 0;
//populate table
//for (uint x = 0; x < entries.GetLength(0); x++) not working
while (x < length)
{
string[] onlyInterestingParts = entries
.TakeHorizontalSlice((uint)x)
.Take(4)
.ToArray();
Main.instance.dataGridViewMatPrime.Rows.Add(onlyInterestingParts);
x++;
}
}
return entries;
TakeHorizontalSlice((uint)x)返回null异常发生在哪一行?它发生在(x
string[] onlyInterestingParts = entries
.TakeHorizontalSlice((uint)x)
.Take(4)
.ToArray();