System.CodeDom.CodeCatchClause Class

Assembly: System.dll
Namespace: System.CodeDom
Summary
Represents a catch exception block.
C# Syntax:
[Serializable]
public class CodeCatchClause
Remarks
CodeCatchClause can be used to represent a catch exception block in a CodeTryCatchFinallyStatement.
See also:
System.CodeDom Namespace | CodeCatchClauseCollection

System.CodeDom.CodeCatchClause Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the CodeCatchClause class.
ctor #2 Overloaded:
.ctor(string localName)

Initializes a new instance of the CodeCatchClause class using the specified local variable name for the exception.
ctor #3 Overloaded:
.ctor(string localName, CodeTypeReference catchExceptionType)

Initializes a new instance of the CodeCatchClause class using the specified local variable name for the exception and exception type.
ctor #4 Overloaded:
.ctor(string localName, CodeTypeReference catchExceptionType, params CodeStatement[] statements)

Initializes a new instance of the CodeCatchClause class using the specified local variable name for the exception, exception type and statement collection.
Public Properties
CatchExceptionType Read-write

Gets or sets the exception type to test for.
LocalName Read-write

Gets or sets the variable name of the exception that the catch clause handles.
Statements Read-only

Gets the statements within the clause.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.CodeDom.CodeCatchClause Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CodeCatchClause class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public CodeCatchClause();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CodeCatchClause class using the specified local variable name for the exception.
C# Syntax:
public CodeCatchClause(
   string localName
);
Parameters:

localName

The name of the local variable declared in the catch clause for the exception. This is optional.

See also:
CodeParameterDeclarationExpression | CodeStatement

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the CodeCatchClause class using the specified local variable name for the exception and exception type.
C# Syntax:
public CodeCatchClause(
   string localName,
   CodeTypeReference catchExceptionType
);
Parameters:

localName

The name of the local variable declared in the catch clause for the exception. This is optional.

catchExceptionType

A CodeTypeReference that indicates the type of exception to catch.

Return to top


Overloaded ctor #4
Summary
Initializes a new instance of the CodeCatchClause class using the specified local variable name for the exception, exception type and statement collection.
C# Syntax:
public CodeCatchClause(
   string localName,
   CodeTypeReference catchExceptionType,
   params CodeStatement[] statements
);
Parameters:

localName

The name of the local variable declared in the catch clause for the exception. This is optional.

catchExceptionType

A CodeTypeReference that indicates the type of exception to catch.

statements

An array of CodeStatement objects that represent the contents of the catch block.

Return to top


Property: CatchExceptionType (read-write)
Summary
Gets or sets the exception type to test for.
C# Syntax:
public CodeTypeReference CatchExceptionType {get; set;}
Remarks
If this is not specified, this defaults to System.Exception.
See also:
CodeParameterDeclarationExpression

Return to top


Property: LocalName (read-write)
Summary
Gets or sets the variable name of the exception that the catch clause handles.
C# Syntax:
public string LocalName {get; set;}
Remarks
This property specifies the name of the local variable of the exception. This local variable is optional. By default, the clause does not have this variable.

Return to top


Property: Statements (read-only)
Summary
Gets the statements within the clause.
C# Syntax:
public CodeStatementCollection Statements {get;}
See also:
CodeStatementCollection | CodeStatement

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~CodeCatchClause();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.