I. System-level exceptions
1. Quasi-de: A system exception caused by the. NET platform should be called. These exceptions are considered as unrecoverable fatal errors.
2. system exceptions are directly derived from the base class named system. systemexception, which is derived from system. Exception.
Systemexception does not add any function except a set of custom constructors.
Public class systemexception: exception
{
// Constructors
}
3. When an exception type is derived from system. systemexception, we can determine that the entity that causes the exception is the. NET Runtime Library rather than the library code being executed.
You can useIs keywordTo verify this conclusion:
NullReferenceException nullRefEx = new NullReferenceException();Console.WriteLine("NullREferenceException is a SystemException? : {0}", nullRefEx is SystemException);
2. Application-level exceptions
1. Custom exceptions should be derived from the system. applicationexception type:
Public class applicationexception: exception
{
// Constructors
}
Just like a system exception, an application exception does not define any other member outside a group of constructors.
2. In terms of function, the only purpose of system. applicationexception is to identify the source of the error.
When the reader processes a file derived from system. during applicationexception, you can imagine that the exception is caused by the code library of the application being executed, rather than. net base class library or.. Net runtime engine.