41 lines
1013 B
C#
41 lines
1013 B
C#
using System;
|
|
|
|
namespace Exercises_C_Sharp.E32_Exceptions
|
|
{
|
|
class Exercise_2
|
|
{
|
|
public static void Start()
|
|
{
|
|
//Sichern sie die Console.ReadLine()-Methode ab, sodass alle Exceptions abgefangen werden. Geben Sie dann die jeweilige Exception aus:
|
|
//Code START
|
|
try
|
|
{
|
|
//Code ENDE
|
|
Console.ReadLine();
|
|
//Code START
|
|
}
|
|
catch(IOException ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
}
|
|
catch(OutOfMemoryException ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
}
|
|
catch(ArgumentOutOfRangeException ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
}
|
|
//Kann auch nur der einzige Catch sein:
|
|
catch(Exception ex)
|
|
{
|
|
Console.WriteLine(ex.ToString());
|
|
}
|
|
|
|
//Code ENDE
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |