#898 – Using Code Snippets to Implement a Custom Exception Type

Visual Studio includes a code snippet that makes it easier to implement a custom exception type.

To add a custom exception type using a code snippet, start by adding a new class file to your project and naming it to match your exception type.

898-001

898-002

 

In the new class, delete the class definition, so that all that remains in the file is a namespace definition.

898-003

 

Create a new blank line within the namespace definition.  Begin typing the word “exception” and look for the icon in the Intellisense dropdown that indicates a code snippet.

898-004

 

Press the TAB key twice so that the code snippet is inserted.  The definition of a new class that derives from Exception will be inserted.

898-005

 

While the name of the new class is highlighted, type the name of your new exception type and press TAB.  The new exception type name will be inserted where appropriate.

898-006

 

Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #898 – Using Code Snippets to Implement a Custom Exception Type

  1. Pingback: Dew Drop – July 30, 2013 (#1,595) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: