Represents errors that occur during application execution.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
Visual Basic (Declaration)
<Serializable Attribute> _
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(Cl assInterfaceType.None)> _
Public Class Exception _
Implements ISerializable, _Exception
Visual Basic (Usage)
Dim instance As Exception
C#
[Serializab leAttribute]
[ComVisibleAttri bute(true)]
[ClassInterfaceAt tribute(ClassInterfaceType.Non e)]
public class Exception : ISerializable, _Exception
Visual C++
[SerializableAttribute]
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(Clas sInterfaceType::None)]
public ref class Exception : ISerializable,
_Exception
J#
/** @attribute SerializableAttribute */
/** @attribute ComVisibleAttribute(true) */
/** @attribute ClassInterfaceAttribute(ClassI nterfaceType.None) */
public class Exception implements ISerializable,
_Exception
JScript
publi c class Exception implements ISerializable, _Exception
Remarks
This class is the base class for all exceptions. When an error occurs, either the system or the currently executing application reports it by throwing an exception containing information about the error. Once thrown, an exception is handled by the application or by the default exception handler.
Try-Catch Blocks
The common language runtime provides an exception handling model that is based on the representation of exceptions as objects, and the separation of program code and exception handling code into try blocks and catch blocks, respectively. There can be one or more catch blocks, each designed to handle a particular type of exception, or one block designed to catch a more specific exception than another block.
If an application handles exceptions that occur during the execution of a block of application code, the code must be placed within a try statement. Application code within a try statement is a try block. Application code that handles exceptions thrown by a try block is placed within a catch statement, and is called a catch block. Zero or more catch blocks are associated with a try block, and each catch block includes a type filter that determines the types of exceptions it handles.
Answered by
Rocky
, an ibibo Master,
at
9:27 AM on August 13, 2008