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