Mono Class Library: System NamespaceSystem.IndexOutOfRangeException Class |
See Also: IndexOutOfRangeException Members
System.Object
System.Exception
System.SystemException
System.IndexOutOfRangeException
|
All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.
Note:[Edit]The following CIL instructions throw IndexOutOfRangeException :
- ldelem.<type>
- ldelema
- stelem.<type>
The following example demonstrates an error that causes a IndexOutOfRangeException exception.
C# Example using System; public class IndexRangeTest { public static void Main() { int[] array = {0,0,0}; try { for (int i = 0; i<4; i++) { Console.WriteLine("array[{0}] = {1}",i,array[i]); } } catch (IndexOutOfRangeException e) { Console.WriteLine("Error: {0}",e); } } }The output is
Example array[0] = 0 array[1] = 0 array[2] = 0 Error: System.IndexOutOfRangeException: Index was outside the bounds of the array. at IndexRangeTest.Main()
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0