using System; public class Test { public static void Requires(bool condition, string message) where TException : Exception { Exception exception = (Exception)Activator.CreateInstance(typeof(TException),message); throw exception; } public static void Main() { try { Requires(true,"Test"); } catch(Exception e) { Console.WriteLine(e); } } }