我有一个命名元组的命名列表,从这个函数中
我试图为命名的元组添加值,但收到错误消息,如:'Index was out of range. Must be non-negative and less than the size of the collection. Arg_ParamName_Name'
请告诉我代码中的错误在哪里.我需要换哪一行?谢谢
查看我的代码:
private class CustomCalculationService : ICustomCalculationService
{
private List<(string sheet, int rowindex, int columnindex)> _ListOfCells;
public List<string>? Sheets { get; set; }
public List<(string sheet, int rowindex, int columnindex)>? ListOfCells { get { return _ListOfCells; } }
public void OnEndCircularReferencesCalculation(IList<CellKey> cellKeys)
{
if (cellKeys.Count > 0)
{
if (_ListOfCells == null)
_ListOfCells = new List<(string sheet, int rowindex, int columnindex)>();
for (int r = 0; r <= cellKeys.Count - 1; r++)
{
_ListOfCells.Add((Sheets[cellKeys[r].SheetId].ToString(), cellKeys[r].RowIndex, cellKeys[r].ColumnIndex));
}
}
}
}