【发布时间】:2019-11-28 09:25:00
【问题描述】:
//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;
我尝试使用 for(在代码中注释),然后使用了一段时间,但它们都在标题中返回错误。我将变量 x 移到 if 之外,但它仍然不起作用。我确信 ENTRIES IS NOT NULL,既因为 if (entries.GetLength(1) != 0) 为真,又因为我在调试器中检查了它。任何回复都非常感谢!
【问题讨论】:
-
异常发生在哪一行?
-
发生在 while (x
标签: c# winforms for-loop while-loop null