Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Index Out of Range Exception and Index Outside the Bounds of Array Exception?

Is there any difference between "Index was out of range exception" and "Index was outside the bounds of the array exception"?

like image 477
Swetha Avatar asked Feb 09 '11 07:02

Swetha


People also ask

What is index out of range exception?

An IndexOutOfRangeException exception is thrown when an invalid index is used to access a member of an array or a collection, or to read or write from a particular location in a buffer. This exception inherits from the Exception class but adds no unique members.

What is index was outside the bounds of the array?

This error is returned by email when a file import fails because of invalid formatting. More specifically, it typically indicates that one or more fields are missing in the file.

What does array out of bounds exception mean?

The ArrayIndexOutOfBounds exception is thrown if a program tries to access an array index that is negative, greater than, or equal to the length of the array. The ArrayIndexOutOfBounds exception is a run-time exception. Java's compiler does not check for this error during compilation.

What does index out of range mean?

Generally, list index out of range means means that you are providing an index for which a list element does not exist.


1 Answers

They're exactly the same thing.

IndexOutOfRangeException is the name of the exception class that is thrown. Its description is given by Visual Studio as "Index was outside the bounds of the array."

This exception is thrown when an attempt is made to access an element of an array with an index that is outside of the bounds of the array.


Note that the IndexOutOfBoundsException class is not part of C# at all, but rather the Java language (or Microsoft's implementation, J#).

like image 96
Cody Gray Avatar answered Sep 28 '22 00:09

Cody Gray