I am new to C # and I find exceptions a bit confusing ... I have a web application with the following code:
try { //do something } catch (TimeoutException t) { Console.WriteLine(t); } catch (TaskCanceledException tc) { Console.WriteLine(tc); } catch (Exception e) { Console.WriteLine(e); }
When I debug the code, it throws an e Exception , the most common, and when I find the exception information, it turns out that it is a TaskCanceledException . Why did not catch TaskCanceledException ? If the exception was a TimeoutException , would it catch a TimeoutException or would it also catch an Exception ? Why is this?
c # exception-handling timeoutexception
Marta
source share