जावा में Array IndexOutofBoundsException होता है। C# में इसका समतुल्य IndexOutOfRangeException है।
IndexOutOfRangeException तब होता है जब अनुक्रमणिका सरणी की सीमा से बाहर होती है।
उदाहरण
using System;
using System.IO;
using System.Collections.Generic;
namespace Demo {
class Program {
static void Main(string[] args) {
int[] arr = new int[3];
arr[0] = 5;
arr[1] = 7;
arr[2] = 8;
arr[4] = 24; // this shows an error
}
}
} आउटपुट
निम्नलिखित आउटपुट है। यह निम्न त्रुटि दिखाता है -
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.