Join Reynald Adolphe for an in-depth discussion in this video Adding exception filters, part of C# 6.0 First Look.
- There may be times you might be handling exceptions…and need to perform specific actions…based on the type of exception.…And we can easily state what to do by catching a specific…exception type like an argument exception…or a file load exception, or file not…found exception, whatever it might be,…and then it will drop into that catch clause.…Or what if we cared about something based on…one of the properties of the exceptions?…Like, the message content.…
Well, in previous versions of C# what we'd need to do…is actually write an if clause that checks that property.…And in this case it will be a message, we check to see…whatever value we cared about, and then…take the action that we needed.…But in C# 6.0, the syntax for these…situations have been simplified by using…the win keyword in an exception filter.…
And let's go ahead and demonstrate how.…Why don't we go ahead and copy and paste the…try catch we had in our previous method,…Test_asyncInCatchFinally, and paste that into…our new test exception filters method.…
- Introducing the new IDE in Visual Studio 2015
- Leveraging nameof expressions
- Using index initializers
- Using await in catch and finally blocks
- Using static
- Resolving conflict instance methods
Skill Level Beginner
1. Touring the Enhanced IDE
2. Expression-Level Features
3. Statement-Level Features
Adding exception filters2m 42s
4. Member Declaration and Initialization Features
5. Improved Debugging
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.