Skip to Main Content
C# 10.0 All-in-One For Dummies
book

C# 10.0 All-in-One For Dummies

by John Paul Mueller
March 2022
Intermediate to advanced content levelIntermediate to advanced
864 pages
19h 46m
English
For Dummies
Content preview from C# 10.0 All-in-One For Dummies

Chapter 9

Some Exceptional Exceptions

IN THIS CHAPTER

Bullet Handling errors via return codes

Bullet Using the exception mechanism instead of return codes

Bullet Plotting your exception-handling strategy

It’s difficult to accept, but occasionally application code doesn’t do what it’s supposed to do, which results in an error. Users are notoriously unreliable as well. No sooner do you ask for an int than a user inputs a double, which also results in an error. Sometimes the code goes merrily along, blissfully ignorant that it is spewing out garbage. However, good programmers write their code to anticipate problems and report them as they occur.

Remember This chapter discusses runtime errors, not compile-time errors, which C# spits out when you try to build your program. Runtime errors occur when the program is running, not at compile time.

The C# exception mechanism is a means for reporting these errors in a way that the calling method can best understand and use to handle the problem. This mechanism has a lot of advantages over the ways that programmers handled errors in the, uh, good old days. This chapter walks ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 9781119839071Purchase Link