Table of Contents

Class Exception

Namespace
System
Assembly
mscorlib.dll

Represents errors that occur during application execution.

public class Exception
Inheritance
Exception
Derived
Inherited Members
Extension Methods

Constructors

Exception()

Initializes a new instance of the Exception class.

public Exception()

Exception(string)

Initializes a new instance of the Exception class with a specified error message.

public Exception(string message)

Parameters

message string

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.

public Exception(string message, Exception innerException)

Parameters

message string

The error message that explains the reason for the exception.

innerException Exception

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

HResult

Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

protected int HResult

Field Value

int

The HRESULT value.///

Properties

InnerException

Gets the Exception instance that caused the current exception.

public Exception InnerException { get; }

Property Value

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.

public virtual string Message { get; }

Property Value

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.

public virtual string StackTrace { get; }

Property Value

string

A string that describes the immediate frames of the call stack.

Methods

ToString()

Creates and returns a string representation of the current exception.

public override string ToString()

Returns

string

A string representation of the current exception.