StatCounter

View My Stats

Saturday, February 14, 2009

To Create Custom exception in C#.Net

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.

No comments: