CodeThrowExceptionStatement Osztály

Definíció

Kivételt jelző utasítást jelöl.

public ref class CodeThrowExceptionStatement : System::CodeDom::CodeStatement
public class CodeThrowExceptionStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeThrowExceptionStatement : System.CodeDom.CodeStatement
type CodeThrowExceptionStatement = class
    inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeThrowExceptionStatement = class
    inherit CodeStatement
Public Class CodeThrowExceptionStatement
Inherits CodeStatement
Öröklődés
CodeThrowExceptionStatement
Attribútumok

Példák

Ez a példa azt mutatja be, hogy egy CodeThrowExceptionStatement új dobáshoz használ egy újat System.Exception.

// This CodeThrowExceptionStatement throws a new System.Exception.
CodeThrowExceptionStatement throwException = new CodeThrowExceptionStatement(
    // codeExpression parameter indicates the exception to throw.
    // You must use an object create expression to new an exception here.
    new CodeObjectCreateExpression(
    // createType parameter inidicates the type of object to create.
    new CodeTypeReference(typeof(System.Exception)),
    // parameters parameter indicates the constructor parameters.
    new CodeExpression[] {} ) );

// A C# code generator produces the following source code for the preceeding example code:

// throw new System.Exception();
 ' This CodeThrowExceptionStatement throws a new System.Exception.
 ' The codeExpression parameter indicates the exception to throw.
 ' You must use an object create expression to new an exception here.
 Dim throwException As New CodeThrowExceptionStatement( _
New CodeObjectCreateExpression( _
    New CodeTypeReference(GetType(System.Exception)), _
    New CodeExpression() {}))

 ' A Visual Basic code generator produces the following source code for the preceeding example code:

 ' Throw New System.Exception

Megjegyzések

CodeThrowExceptionStatement egy kivételt okozó utasítást jelölhet. A kifejezésnek az osztályból Exception származó típusú példányra mutató hivatkozásnak kell lennie vagy annak kiértékelése.

A ToThrow tulajdonság megadja a kiveendő kivételt.

Konstruktorok

Name Description
CodeThrowExceptionStatement()

Inicializálja a CodeThrowExceptionStatement osztály új példányát.

CodeThrowExceptionStatement(CodeExpression)

Inicializálja az osztály új példányát CodeThrowExceptionStatement a megadott kivételtípus-példánnyal.

Tulajdonságok

Name Description
EndDirectives

Lekéri a CodeDirectiveCollection végfelhasználói irányelveket tartalmazó objektumot.

(Öröklődés forrása CodeStatement)
LinePragma

Lekéri vagy beállítja azt a sort, amelyen a kódutasítás történik.

(Öröklődés forrása CodeStatement)
StartDirectives

Lekéri a CodeDirectiveCollection kezdő irányelveket tartalmazó objektumot.

(Öröklődés forrása CodeStatement)
ToThrow

Lekéri vagy beállítja a kivételt.

UserData

Lekéri az aktuális objektum felhasználó által definiálható adatait.

(Öröklődés forrása CodeObject)

Metódusok

Name Description
Equals(Object)

Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal.

(Öröklődés forrása Object)
GetHashCode()

Ez az alapértelmezett kivonatoló függvény.

(Öröklődés forrása Object)
GetType()

Lekéri az Type aktuális példányt.

(Öröklődés forrása Object)
MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
ToString()

Az aktuális objektumot jelképező sztringet ad vissza.

(Öröklődés forrása Object)

A következőre érvényes: