hharry wrote:
hello all,
quick syntax question. i am writing a custom exception class and came
across an example:
public class dataProvException : ApplicationException
{
public dataProvException()
{
//
// TODO: Add constructor logic here
//
}
public dataProvException(string msg) : base(msg)
{
//
// TODO: Add constructor logic here
//
}
}
in the second constructor, what is the purpose of : base(msg) ?
i understand that the base keyword ids used to access members of the
base class ?
That calls a base class constructor. In this case you're passing the
exception message to a base class constructor that has one string
parameter.
Also, it is recommended to avoid the use of ApplicationException. If I
remember correctly there was some discussion on whether or not to
deprecate it, but it doesn't appear that happened in 2.0. The idea was
that SystemException would be used for exceptions thrown by the CLR and
ApplicationException would be used for non-CLR exceptions. The problem
is Microsoft didn't follow their own guideline so what seemed like a
good idea is nearly useless now.
http://blogs.msdn.com/kcwalina/archi...23/644822.aspx
Brian