
C# 7 and .NET Core: Modern Cross-Platform Development

You've seen several scenarios when errors have occurred. C# calls where an exception has been thrown. A good practice is to avoid writing code that will throw an exception whenever possible, but sometimes you can't. In those scenarios, you must catch the exception and handle it.
As you have seen, the default behavior of a console application is to display details about the exception in the output and then stop running the application.
The default behavior of a Windows desktop application is to display details about the exception in a dialog box and allow the user to choose to either continue or stop running the application. You can take control over how to handle exceptions using the try
statement.
Add a new console application project named Ch03_HandlingExceptions
.
When you know that a statement can cause an error, you should wrap that statement in a try
block. For example, parsing from a string to a number can cause an error. We do not have to do anything...
Change the font size
Change margin width
Change background colour