CodeThrowExceptionStatement クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > CodeThrowExceptionStatement クラスの意味・解説 

CodeThrowExceptionStatement クラス

例外スローするステートメント表します

名前空間: System.CodeDom
アセンブリ: System (system.dll 内)
構文構文

<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeThrowExceptionStatement
    Inherits CodeStatement
Dim instance As CodeThrowExceptionStatement
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeThrowExceptionStatement :
 CodeStatement
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeThrowExceptionStatement
 : public CodeStatement
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeThrowExceptionStatement extends
 CodeStatement
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeThrowExceptionStatement extends
 CodeStatement
解説解説

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

ToThrow プロパティは、スローする例外指定します

使用例使用例

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.Object
   System.CodeDom.CodeObject
     System.CodeDom.CodeStatement
      System.CodeDom.CodeThrowExceptionStatement
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CodeThrowExceptionStatement クラス」の関連用語

CodeThrowExceptionStatement クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CodeThrowExceptionStatement クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS