public void SetCells(List <Cell> cells) { this.cells = new Cell[height, width]; if (width * height != cells.Count) { throw new System.Exception("The size of the accepted values is not equal to the size of the set values"); } for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { this.cells[i, j] = cells[0]; cells.RemoveAt(0); } } }