>To Create Custom exception in C#.Net

>#region Custom Exception Classes
class ExTask : Exception
{
public ExTask()
{ }

public ExTask(string message)
: base(message)
{ }
}
#endregion

==================================================================
To catch the custom Exception :

catch (ExTask ex)
{
// Do to Log Handler
}

==================================================================
For the above example “ExTask” is the custom exception name.

1.your Exception wants to inherit the exception base class.

2.You have to create a default constructor,,,, two method we
wants to call the base class Exception contructor.

Advertisement

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.