C# 引用列表中数组中的元素

C# 引用列表中数组中的元素,c#,arrays,list,C#,Arrays,List,我创建了一个函数,返回数组列表,每个数组包含3个单元格。但我不知道如何引用列表中的数组的每个元素。代码如下: public List<Cell[]> GetEmptyRows() { var selection = new List<Cell[]>(); selection.ForEach(entry => entry.Initialize()); // Not sure if this is necessary but le

我创建了一个函数,返回数组列表,每个数组包含3个单元格。但我不知道如何引用列表中的数组的每个元素。代码如下:

public List<Cell[]> GetEmptyRows()
    {
        var selection = new List<Cell[]>();
        selection.ForEach(entry => entry.Initialize()); // Not sure if this is necessary but let's keep it here for now

        for (int i = 0; i < this.cells.GetLength(0); i++)
        {
            var rows = new List<Cell[]>() { cells[i,i].HorizontalRelatives(this), cells[i,i].VerticalRelatives(this) };

            if (i == 1)
            {
                rows.Add(cells[i, i].DiagonalRelatives(this));
                rows.Add(cells[i, i].DiagonalRelatives2(this));
            }

            selection = rows.FindAll(array => array.Length.Equals(3));
        }

        return selection;
    }
公共列表GetEmptyRows()
{
var selection=新列表();
selection.ForEach(entry=>entry.Initialize());//不确定这是否必要,但现在让我们将其保留在这里
for(int i=0;iarray.Length.Equals(3));
}
返回选择;
}

我不确定,如果这是您想要的,但是,要引用某个数组的单个元素,只需通过[]访问它们

public Cell GetCell(List<Cell[]> list, int row, int cell)
{
    if (list.Count < row || list[row].Length < cell)
        return;

    return list[row][cell];
}
public Cell GetCell(列表、整数行、整数单元格)
{
if(list.Count
这应该能奏效


当然,不必将目标列表作为参数传递。您可以将此函数放在保存列表的类中。

您的代码的哪一部分不起作用?那么,您可以在列表中获得数组:
var a=list[0]
然后像往常一样使用数组?你哪里有问题?是的,这很好用,我希望有一种方法可以在语法上做得更简单,但这确实有效。