Join Gerry O'Brien for an in-depth discussion in this video Challenge: Handle an error, part of Learning C# (2014).
In this challenge, you're going to write structured exception handling to handle a…specific error that will be generated by the code you see on screen.…The challenge starts with code that I have already written, where…I'm declaring integer values, an object value, and a string value.…I will attempt to perform a cast using this statement here.…Your objective in this challenge is to use the existing code in Visual Studio.…Create the appropriate exception handling routine to wrap…the protected code that will generate the error.…You'll need to catch the InvalidCastException that is generated,…and you'll want to output the exception message to the screen.…
With the starter code, writing the exception…handling should take you approximately 10 minutes.…
- Installing C#
- Working with loops
- Controlling program flow
- Using variables
- Building functions
- Creating and instantiating classes
- Catching errors
- Managing resources with the garbage collector
- Building collections
Skill Level Beginner
1. Introducing C#
2. C# Language Elements
3. Object-Oriented Programming in C#
4. Structured Exception Handling
5. Resource Management in C#
6. Extensible Types in C#
7. Windows Apps in C#
- 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.