【bug】“Attempted to divide by zero.”和“Index was outside the bounds of the array.”

bug

    • “Attempted to divide by zero.”
    • “Index was outside the bounds of the array.”

“Attempted to divide by zero.”

  1. “System.DivideByZeroException:“Attempted to divide by zero.”
    “试图除以零。”

出错地方:
【bug】“Attempted to divide by zero.”和“Index was outside the bounds of the array.”_第1张图片
因为我的i是从0开始的,所以就会出现n%0的情况,一个数除余0,即一个数除以0余几,而0不能被除,所以出错。

“Index was outside the bounds of the array.”

  1. System.IndexOutOfRangeException:“Index was outside the bounds of the array.”
    “索引超出了数组的界限。

出错地方:
【bug】“Attempted to divide by zero.”和“Index was outside the bounds of the array.”_第2张图片
因为不知道数组的长度,所以没有设长度,导致后续在数组里添加数值时产生了数组越界。
解决后:【bug】“Attempted to divide by zero.”和“Index was outside the bounds of the array.”_第3张图片


更多内容请前往主页置顶或点击链接直达:【unity3D】游戏开发专栏的目录

你可能感兴趣的:(#,遇到的问题,bug,unity,学习,c#)