I have an array with size[5]
. I added 5 values into this array and then removed the values. Now my array have only one value. If I add another value to this array it shows the error Index was outside the bounds of the array
.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
由
翻译强力驱动
问题:
回答1:
If you have an array of size 5 you can add values 0 to 4 (arrays start at index 0):
object[] arr = new object[5]; arr[0] = new object(); arr[4] = new object(); // this will give your Index was outside the bounds of the array exception: arr[5] = new object();