Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Articulos.Cap04.Excepciones.Parte5
- {
- public sealed class UsoIndexOutOfRangeException
- {
- public static void Main()
- {
- int[] arregloEnteros = new int[5];
- // Agrega 5 elementos al arreglo:
- for (int i = 0; i < arregloEnteros.Length; ++i)
- {
- arregloEnteros[i] = i + 1;
- }
- try
- {
- // Intengo de acceder a un elemento del
- // arreglo con un índice superior:
- Console.WriteLine (arregloEnteros[5].ToString());
- }
- catch (IndexOutOfRangeException ioore)
- {
- Console.WriteLine ("Mensaje de error: `{0}`", ioore.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement