diff --git a/Program.cs b/Program.cs index 8767beb..d219b02 100644 --- a/Program.cs +++ b/Program.cs @@ -3,9 +3,9 @@ class Program { static void Main(string[] args) { int scelta = 0; - double input = 0; + int input = 0; bool eccezione; - int[] array = null; + int[] array; do { @@ -53,7 +53,7 @@ class Program { Console.Write("Inserire un numero: "); eccezione = false; try { - input = Convert.ToDouble(Console.ReadLine()); + input = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Numero non valido"); @@ -87,19 +87,21 @@ class Program { Console.ReadKey(); } - static double Divisione(double input) { + static double Divisione(int input) { Random r = new Random(); bool eccezione; - double ritorno = 0; + double ritorno; do { + int numero = r.Next(0, 4); eccezione = false; try { - ritorno = input / r.Next(0, 4); + ritorno = input / numero; } catch (DivideByZeroException) { Console.WriteLine("Impossibile dividere per 0."); Pausa(); eccezione = true; + ritorno = double.NaN; } } while (eccezione); return ritorno; @@ -132,6 +134,9 @@ class Program { Pausa(); eccezione = true; } + catch (IndexOutOfRangeException e) { + Console.WriteLine(e.Message); + } } while (eccezione); } diff --git a/bin/Debug/net9.0/eccezioni_1.dll b/bin/Debug/net9.0/eccezioni_1.dll index 2b428f3..8bf4e06 100644 Binary files a/bin/Debug/net9.0/eccezioni_1.dll and b/bin/Debug/net9.0/eccezioni_1.dll differ diff --git a/bin/Debug/net9.0/eccezioni_1.pdb b/bin/Debug/net9.0/eccezioni_1.pdb index 73bf795..73d7551 100644 Binary files a/bin/Debug/net9.0/eccezioni_1.pdb and b/bin/Debug/net9.0/eccezioni_1.pdb differ diff --git a/obj/Debug/net9.0/eccezioni_1.AssemblyInfo.cs b/obj/Debug/net9.0/eccezioni_1.AssemblyInfo.cs index a24d2ec..0579539 100644 --- a/obj/Debug/net9.0/eccezioni_1.AssemblyInfo.cs +++ b/obj/Debug/net9.0/eccezioni_1.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("eccezioni_1")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0dc3eed65f04928e028a1afc17f4bc8f367f78bd")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+16f1dea94221582c4d8b3ad11e57771f328fe1eb")] [assembly: System.Reflection.AssemblyProductAttribute("eccezioni_1")] [assembly: System.Reflection.AssemblyTitleAttribute("eccezioni_1")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/obj/Debug/net9.0/eccezioni_1.AssemblyInfoInputs.cache b/obj/Debug/net9.0/eccezioni_1.AssemblyInfoInputs.cache index f1c028f..c9950f7 100644 --- a/obj/Debug/net9.0/eccezioni_1.AssemblyInfoInputs.cache +++ b/obj/Debug/net9.0/eccezioni_1.AssemblyInfoInputs.cache @@ -1 +1 @@ -ee7e98605e9c5564468cd86c1b1c002f51995b579fee2b845d8a36b5f951a60b +48a3fed5e6086b9afebbe353b2777958bf4a496d106ab6a3b2c1f2232e423364 diff --git a/obj/Debug/net9.0/eccezioni_1.dll b/obj/Debug/net9.0/eccezioni_1.dll index 2b428f3..8bf4e06 100644 Binary files a/obj/Debug/net9.0/eccezioni_1.dll and b/obj/Debug/net9.0/eccezioni_1.dll differ diff --git a/obj/Debug/net9.0/eccezioni_1.pdb b/obj/Debug/net9.0/eccezioni_1.pdb index 73bf795..73d7551 100644 Binary files a/obj/Debug/net9.0/eccezioni_1.pdb and b/obj/Debug/net9.0/eccezioni_1.pdb differ diff --git a/obj/Debug/net9.0/ref/eccezioni_1.dll b/obj/Debug/net9.0/ref/eccezioni_1.dll index a244184..ed5b7e2 100644 Binary files a/obj/Debug/net9.0/ref/eccezioni_1.dll and b/obj/Debug/net9.0/ref/eccezioni_1.dll differ diff --git a/obj/Debug/net9.0/refint/eccezioni_1.dll b/obj/Debug/net9.0/refint/eccezioni_1.dll index a244184..ed5b7e2 100644 Binary files a/obj/Debug/net9.0/refint/eccezioni_1.dll and b/obj/Debug/net9.0/refint/eccezioni_1.dll differ