-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals
By :

You’ve seen several scenarios where errors have occurred when converting types. Some languages return error codes when something goes wrong. .NET uses exceptions that are richer and designed only for failure reporting. When this happens, we say a runtime exception has been thrown.
Other systems might use return values that could have multiple uses. For example, if the return value is a positive number, it might represent the count of rows in a table, or if the return value is a negative number, it might represent some error code.
When an exception is thrown, the thread is suspended and if the calling code has defined a try-catch
statement, then it is given a chance to handle the exception. If the current method does not handle it, then its calling method is given a chance, and so on up the call stack.
As you have seen, the default behavior of a console app is to output a message about the exception, including a stack trace, and then stop running...