我的代碼的邊界之外System.IndexOutOfRangeException:索引是數組c#
public bool Add(ConquerItem item)
{
if (objects.Length < item.Position)
return false;
if (objects[item.Position - 1] == null)
{
item.IsWorn = true;
UpdateItemview(item);
objects[item.Position - 1] = item;
item.Position = item.Position;
item.Send(Owner);
Owner.LoadItemStats();
Owner.SendScreenSpawn(Owner.Entity, false);
return true;
}
else return false;
}
錯誤說
System.IndexOutOfRangeException:指數是 陣列的邊界之外
這個錯誤發生在哪裏?你調試過代碼嗎? –
當我嘗試在遊戲中添加項目時,我在控制檯中出現此錯誤 –
如果您在單步調試中調試,您將在特定行中得到它,請嘗試。 –