0
我有一個數組。我在這個數組中添加了5個值,然後刪除了這些值。現在我的數組只有一個值。如果我向該陣列添加另一個值,則會顯示錯誤 Index was outside the bounds of the array
。索引超出了數組的範圍c#
我有一個數組。我在這個數組中添加了5個值,然後刪除了這些值。現在我的數組只有一個值。如果我向該陣列添加另一個值,則會顯示錯誤 Index was outside the bounds of the array
。索引超出了數組的範圍c#
如果你有大小5的陣列,您可以添加值0-4(數組索引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();
關於與你寫必須說明具體問題和代碼問題,問題包括*在問題本身中重現它的有效代碼。 –
我們喜歡看代碼,所以如果你不介意,請給我們看看。 – Ehsan
添加和從陣列中刪除?我懷疑這不是一個數組。 – Theraot