Generally, the exception class system. Exception is derived from system. object.
These two important classes are derived from system. Exception:
System. systemexception ---- used for exceptions thrown by the. NET Runtime
System. applicationexception ---- third-party-defined exception base class
Stackoverflowexception ---- the memory area allocated to the stack is full and an exception is thrown.
Endofstreamexception ---- thrown at the end of the file
Overflowexception ---- if you want to forcibly convert data in the checked environment, an exception will be thrown.
Capture exceptions, for example:
try{ // code for normal execution}catch{ // error handling}finally{ // clean up}
User-defined exception type, for example:
class SalesSpyFoundException:ApplicationException{ public SalesSpyFoundException(string spyName) :base("Sales spy found,with name" + spyName) { } public SalesSpyFoundException( string spyName,Exception innerException) :base( "Sales spy found with name" + spyName,innerException) { }}
C # Study Notes ---- errors and exceptions