Skip to content

Instantly share code, notes, and snippets.

@d630
Created June 19, 2018 04:14
Show Gist options
  • Save d630/a31d63a05a41f0e32c3b4b8edce1fbca to your computer and use it in GitHub Desktop.
Save d630/a31d63a05a41f0e32c3b4b8edce1fbca to your computer and use it in GitHub Desktop.
Throwing an exception
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