//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 之外,但它仍然不起作用。我确定条目不是空的,因为 if (条目。GetLength(1( != 0( 为真,因为我在调试器中检查了它。任何回复将不胜感激!
问题显示在 while (x <长度(,但它已打开>
string[] onlyInterestingParts = entries
.TakeHorizontalSlice((uint)x)
.Take(4)
.ToArray();
TakeHorizontalSlice((uint(x( 返回 null