Ryan McBeth
Ryan McBeth
@RyanMcBethProgramming·1.1M subscribers·2K videos

C# Exception Handling Interview Questions

Posted

May 8, 2021

Views

2,056

Likes

119

Comments

18

Engagement

6.66%

Search the Record

Indexed

Every word spoken in this episode is indexed. Type any phrase to jump straight to the moment it was said.

Type any word or phrase that may have been spoken. Click a result to seek the player to that exact moment.

Try a name, a topic, or a quoted line

YouTube Description

as posted by the channel

Exception handling in C# is an important part of .NET, especially when dealing with unknown input / output such as files, database or network connections. Good exception handling can let you recover from the kind of programming error that is likely to crash your program.

Think of it like sticking a piece of twine onto a method. If the method fails, you can rewind the twine to where you started and notify the user that there is a problem or attempt recovery.

Exception handling works with three keywords:

TRY - Which is the block where you write the code you want to handle.

CATCH - which is the block where you recover and can examine the exception to determine a course of action.

and FINALLY which is guaranteed to be executed if TRY or CATCH is run so that you can clean up connections.

Exceptions should be reserved for truly EXCEPTIONAL situations, not just used for regular program control.

A TRY statement can support multiple CATCH statements, each of which may catch a different kind of exception.

TRY doesn't always need to be paired with a CATCH. You can also use TRY-FINALLY which is the equivalent of the USING statement.

The code for this can be found at:

ryanmcbeth.com

Guests & Subjects Covered

A TRYCATCH You

Sentinel Indexing in Progress

Metadata and chapters are available. Claim extraction for this episode is pending.

All video content is delivered via YouTube embedded players in accordance with the YouTube Terms of Service. Sentinel provides research tools that promote discovery and accountability across political media.

C# Exception Handling Interview Questions · Ryan McBeth · Sentinel