To Create Custom exception in C#.Net
#region Custom Exception Classesclass 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:
Post a Comment