How to throw a custom exception?
The usual try - catch - finally - end try format has to be followed. However, in this case, instead of using the preset exceptions from the System.Exception, you define your OwnException class and inherit Exception or ApplicationException class.
You need to define three constructors in your OwnException Class: One without parameters, other with String parameter for error message and the last one has to have one parameter as a String and other as an Inner exception object.
Example:class OwnException : ApplicationException
{
public OwnException() : base() { }
public OwnException(string s) : base(s) { }
public OwnException(string s, Exception ae) : base(s, ae) { }
}