Exception Handling

In the previous chapter, we looked at functions. Despite the best efforts of programmers to write robust code, functions will, at some point, generate exceptions. This could be for a number of reasons, such as a missing file or folder, an empty or null value, the location can't be written to, or the user is denied access. So, with that in mind, in this chapter, you will learn about appropriate ways to use exception handling to produce clean C# code. First, we will start by looking at checked and unchecked exceptions with regards to arithmetic OverflowExceptions. We will look at what they are, why they are used, and some examples of them being used in code.

Then, we'll look at how we can avoid the NullPointerReference exception. ...

Get Clean Code in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.