Csharp/C Sharp by API/System/IndexOutOfRangeException
Версия от 15:31, 26 мая 2010; (обсуждение)
IndexOutOfRangeException.Message
using System;
public class Example10_2 {
public static void Main() {
try {
int[] intArray = new int[5];
for (int counter = 0; counter <= intArray.Length; counter++)
{
intArray[counter] = counter;
Console.WriteLine("intArray[" + counter + "] = " + intArray[counter]);
}
}
catch (IndexOutOfRangeException e)
{
Console.WriteLine("IndexOutOfRangeException occurred");
Console.WriteLine("Message = " + e.Message);
Console.WriteLine("Stack trace = " + e.StackTrace);
}
}
}