linux-packaging-mono/mono/tests/catch-generics.2.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

31 lines
579 B
C#

using System;
class Test<T> where T :Exception {
public void test_catch () {
try {
throw new RankException ();
} catch (T) {
}
}
}
public class Program
{
delegate void Action();
static void ExpectedException<T>(Action action) where T: Exception
{
try {
action();
Console.WriteLine("Expected Exception: " + typeof(T).FullName);
} catch (T) { }
}
public static void Main()
{
ExpectedException<DivideByZeroException>(delegate() { throw new DivideByZeroException(); });
Test<RankException> t = new Test<RankException> ();
t.test_catch ();
}
}