Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- string name;
- int[] Tablica = new int[5];
- Console.Write("Podaj swoje imię\t");
- name = Console.ReadLine();
- try
- {
- Console.Write("Podaj element tablicy: \t");
- Tablica[5] = int.Parse(Console.ReadLine());
- Console.WriteLine($"Piąty element tablicy ma wartość {Tablica[5]}");
- }
- catch(IndexOutOfRangeException e)
- {
- Console.WriteLine($"{name} Indeks tablicy liczony jest od zera.\nPróbujesz przypisać wartość do nieistniejącego elementu.\nSpróbuj ponownie");
- Tablica[4] = int.Parse(Console.ReadLine());
- Console.WriteLine(e.Message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement