Uebungsaufgaben_ITFS_3_SS_2025/Exercises/E32_Exceptions/Exercise_4.cs
s.schueler.doz 8b634a0758 E32 Ex1 - 4
2025-03-03 12:52:42 +01:00

65 lines
1.5 KiB
C#

using System;
namespace Exercises_C_Sharp.E32_Exceptions
{
class Exercise_4
{
public static void Start()
{
//Welche Exceptions könnten in der Methode possible fliegen? Fangen Sie alle möglichen Exceptions ab!
try
{
possible();
}
//Code START
catch(IOException)
{
}
catch(OutOfMemoryException)
{
}
catch(ArgumentOutOfRangeException)
{
}
catch(FormatException)
{
}
catch(OverflowException)
{
}
catch(DivideByZeroException)
{
}
catch(IndexOutOfRangeException)
{
}
catch(ArgumentNullException)
{
}
//Code ENDE
}
#pragma warning disable CS8602, CS8600
static void possible()
{
Console.WriteLine("Bitte geben Sie eine Zahl ein:");
int i = Convert.ToInt32(Console.ReadLine());
double d = Math.PI / i;
Console.WriteLine("Ihr Ergebnis ist: {0}", d);
Console.WriteLine("Bitte geben Sie nun einen String ein:");
string s = Console.ReadLine();
Console.WriteLine("Der dritte Wert ist {0}", s[2]);
Console.WriteLine("Das Wort groß geschrieben lautet {0}", s.ToUpper());
}
#pragma warning restore CS8602, CS8600
}
}