배열 목록을 반환하는 함수를 만들었습니다. 각 배열에는 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;
}
코드 중 어떤 부분이 작동하지 않습니까? – Tarec
글쎄, 당신은 목록 내부에서 배열을 얻을 수 있습니다 :'var a = list [0];'그리고 평소처럼 배열을 사용합니까? 어디에서 문제가 있습니까? –