Created
June 19, 2018 04:14
-
-
Save d630/a31d63a05a41f0e32c3b4b8edce1fbca to your computer and use it in GitHub Desktop.
Throwing an exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Expections | |
{ | |
class Fehler : ApplicationException | |
{ | |
public Fehler() : base() | |
{ | |
} | |
public Fehler(string m) : base(m) | |
{ | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int i = 10; | |
try | |
{ | |
if (i == 10) | |
throw (new Fehler("Error: Zahl ist 10")); | |
} | |
catch (NotSupportedException ex) | |
{ | |
} | |
catch (Fehler ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
finally | |
{ | |
Console.ReadKey(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment