Class Exception
Represents errors that occur during application execution.
Inheritance
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
public class Exception
Constructors
| Improve this Doc View SourceException()
Initializes a new instance of the Exception class.
Declaration
public Exception()
Exception(String)
Initializes a new instance of the Exception class with a specified error message.
Declaration
public Exception(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message that describes the error. |
Exception(String, Exception)
Initializes a new instance of the Exception class with a specified error message and a reference to the inner exception that is the cause of this exception.
Declaration
public Exception(string message, Exception innerException)
Parameters
Type | Name | Description |
---|---|---|
String | message | The error message that explains the reason for the exception. |
Exception | innerException | The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified. |
Fields
| Improve this Doc View SourceHResult
Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.
Declaration
protected int HResult
Field Value
Type | Description |
---|---|
Int32 | The HRESULT value./// |
Properties
| Improve this Doc View SourceInnerException
Gets the Exception instance that caused the current exception.
Declaration
public Exception InnerException { get; }
Property Value
Type | Description |
---|---|
Exception | An instance of Exception that describes the error that caused the current exception. The InnerException property returns the same value as was passed into the constructor, or a null reference (Nothing in Visual Basic) if the inner exception value was not supplied to the constructor. This property is read-only. |
Message
Gets a message that describes the current exception.
Declaration
public virtual string Message { get; }
Property Value
Type | Description |
---|---|
String | The error message that explains the reason for the exception, or an empty string(""). |
StackTrace
Gets a string representation of the immediate frames on the call stack.
Declaration
public virtual string StackTrace { get; }
Property Value
Type | Description |
---|---|
String | A string that describes the immediate frames of the call stack. |
Methods
| Improve this Doc View SourceToString()
Creates and returns a string representation of the current exception.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string representation of the current exception. |