索引在数组的边界之外,但是当数组有项目时引用 0 索引

Index was outside the bounds of the array, but refer to 0 index while array have items

我有例外 "Index was outside the bounds of the array", 但是我引用的 22 个模型项和数组索引是 0 (Model[0])

您可以尝试用 foreach 循环代替 for 循环。

@foreach(var product in Model)
{
     <span>@product.Link<span>
}

与"Index out of array exception"无关。错误来自其他地方。