“Attempted to divide by zero.”

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

出错地方:
在这里插入图片描述
因为我的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.”
    “索引超出了数组的界限。

出错地方:
在这里插入图片描述
因为不知道数组的长度,所以没有设长度,导致后续在数组里添加数值时产生了数组越界。
解决后:在这里插入图片描述


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

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐