fork(1) download
  1. using System;
  2.  
  3. public class Test<T> where T : Exception {
  4.  
  5. public void TryTest() {
  6. try {
  7. int zero = 0;
  8. int a = 1 / zero;
  9. } catch(T t) {
  10. Console.WriteLine($"Error: {t.Message}");
  11. }
  12. }
  13.  
  14. }
  15.  
  16. public class MainTest {
  17.  
  18. public static void Main() {
  19. var test = new Test<ArithmeticException>();
  20. test.TryTest();
  21. }
  22.  
  23. }
Success #stdin #stdout 0.01s 131648KB
stdin
Standard input is empty
stdout
Error: Attempted to divide by zero.