CodeThrowExceptionStatement クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class CodeThrowExceptionStatement Inherits CodeStatement
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeThrowExceptionStatement : CodeStatement
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class CodeThrowExceptionStatement : public CodeStatement

CodeThrowExceptionStatement は、例外をスローするステートメントを表すことができます。式は、Exception クラスから派生した型のインスタンス参照であるか、またはインスタンス参照として評価される必要があります。

CodeThrowExceptionStatement を使用して、新しい 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
// 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. array<CodeExpression^>^temp0; CodeThrowExceptionStatement^ throwException = gcnew CodeThrowExceptionStatement( gcnew CodeObjectCreateExpression( gcnew CodeTypeReference( System::Exception::typeid ),temp0 ) ); // 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. 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(System.Exception.class.ToType()) , // parameters parameter indicates the constructor parameters. new CodeExpression[]{})); // A VJ# code generator produces the following source code for // the preceeding example code: // throw new System.Exception();

System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeThrowExceptionStatement


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CodeThrowExceptionStatement クラスのページへのリンク