CodeIterationStatementとは? わかりやすく解説

CodeIterationStatement クラス

for ステートメント、またはループの続行条件としてテスト式を使用するステートメントのブロックを反復処理するループを表します。

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

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

CodeIterationStatement を使用して、for ループを表す例を次に示します。

 ' Declares and initializes an integer variable named testInt.
 Dim testInt As New CodeVariableDeclarationStatement(GetType(Integer),
 "testInt", New CodePrimitiveExpression(0))
 
 ' Creates a for loop that sets testInt to 0 and continues incrementing
 testInt by 1 each loop until testInt is not less than 10.
    ' initStatement parameter for pre-loop initialization.
    ' testExpression parameter indicates the epxression to test for
 continuation condition.
    ' incrementStatement parameter indicates statement to execute after
 each iteration.
    ' statements parameter contains the statements to execute during
 each interation of the loop.
    ' Each loop iteration the value of the integer is output using the
 Console.WriteLine method.

 Dim forLoop As New CodeIterationStatement(
 _
    New CodeAssignStatement(New CodeVariableReferenceExpression("testInt"),
 New CodePrimitiveExpression(1)), _
    New CodeBinaryOperatorExpression(New CodeVariableReferenceExpression("testInt"),
 _ 
        CodeBinaryOperatorType.LessThan, New CodePrimitiveExpression(10)),
 _
    New CodeAssignStatement(New CodeVariableReferenceExpression("testInt"),
 _
    New CodeBinaryOperatorExpression(New CodeVariableReferenceExpression("testInt"),
 _
        CodeBinaryOperatorType.Add, New CodePrimitiveExpression(1))),
 _
    New CodeStatement() {New CodeExpressionStatement( _
        New CodeMethodInvokeExpression(New
 CodeMethodReferenceExpression(New CodeTypeReferenceExpression("Console"),
 "WriteLine"), _ 
                New CodeMethodInvokeExpression(New
 CodeVariableReferenceExpression("testInt"), "ToString")))})


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

'     Dim testInt As Integer = 0
'     testInt = 1
'     Do While (testInt < 10)
'         Console.WriteLine(testInt.ToString)
'         testInt = (testInt + 1)
// Declares and initializes an integer variable named testInt.
CodeVariableDeclarationStatement testInt = new CodeVariableDeclarationStatement(typeof(int),
 "testInt", new CodePrimitiveExpression(0) );

// Creates a for loop that sets testInt to 0 and continues incrementing
 testInt by 1 each loop until testInt is not less than 10.
CodeIterationStatement forLoop = new CodeIterationStatement(
    // initStatement parameter for pre-loop initialization.
    new CodeAssignStatement( new CodeVariableReferenceExpression("testInt"),
 new CodePrimitiveExpression(1) ),
    // testExpression parameter to test for continuation condition.
    new CodeBinaryOperatorExpression( new CodeVariableReferenceExpression("testInt"),
 
        CodeBinaryOperatorType.LessThan, new CodePrimitiveExpression(10)
 ),
    // incrementStatement parameter indicates statement to execute after
 each iteration.
    new CodeAssignStatement( new CodeVariableReferenceExpression("testInt"),
 new CodeBinaryOperatorExpression( 
        new CodeVariableReferenceExpression("testInt"),
 CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1) ))
,
    // statements parameter contains the statements to execute during
 each interation of the loop.
    // Each loop iteration the value of the integer is output using
 the Console.WriteLine method.
    new CodeStatement[] { new CodeExpressionStatement(
 new CodeMethodInvokeExpression( new CodeMethodReferenceExpression(
 
        new CodeTypeReferenceExpression("Console"),
 "WriteLine" ), new CodeMethodInvokeExpression( 
        new CodeVariableReferenceExpression("testInt"),
 "ToString" ) ) ) } );

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

//     int testInt = 0;
//     for (testInt = 1; (testInt < 10); testInt = (testInt + 1))
 {
//        Console.WriteLine(testInt.ToString());
// Declares and initializes an integer variable named testInt.
CodeVariableDeclarationStatement^ testInt = gcnew CodeVariableDeclarationStatement(
 int::typeid,"testInt",gcnew CodePrimitiveExpression(
 (int^)0 ) );
array<CodeMethodInvokeExpression^>^writelineparams = {gcnew CodeMethodInvokeExpression(
 gcnew CodeVariableReferenceExpression( "testInt" ),"ToString",nullptr
 )};
array<CodeStatement^>^codestatements = {gcnew CodeExpressionStatement( gcnew
 CodeMethodInvokeExpression( gcnew CodeMethodReferenceExpression( gcnew CodeTypeReferenceExpression(
 "Console" ),"WriteLine" ),writelineparams ) )};

// Creates a for loop that sets testInt to 0 and continues incrementing
 testInt by 1 each loop until testInt is not less than 10.

// Each loop iteration the value of the integer is output using the
 Console.WriteLine method.
CodeIterationStatement^ forLoop = gcnew CodeIterationStatement( gcnew CodeAssignStatement(
 gcnew CodeVariableReferenceExpression( "testInt" ),gcnew CodePrimitiveExpression(
 1 ) ),gcnew CodeBinaryOperatorExpression( gcnew CodeVariableReferenceExpression( "testInt" ),CodeBinaryOperatorType::LessThan,gcnew CodePrimitiveExpression( 10
 ) ),gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "testInt" ),gcnew CodeBinaryOperatorExpression( gcnew CodeVariableReferenceExpression( "testInt" ),CodeBinaryOperatorType::Add,gcnew CodePrimitiveExpression( 1 ) ) ),codestatements );

// A C# code generator produces the following source code for the preceeding
 example code:
//     int testInt = 0;
//     for (testInt = 1; (testInt < 10); testInt = (testInt + 1))
 {
//        Console.WriteLine(testInt.ToString());
// Declares and initializes an integer variable named testInt.
CodeVariableDeclarationStatement testInt = new 
    CodeVariableDeclarationStatement(int.class.ToType(),
 
    "testInt", new CodePrimitiveExpression((Int32)0));
// Creates a for loop that sets testInt to 0 and continues 
// incrementing testInt by 1 each loop until testInt is not less than
 10.
CodeIterationStatement forLoop = new CodeIterationStatement(
    // initStatement parameter for pre-loop initialization.
    new CodeAssignStatement(new CodeVariableReferenceExpression(
    "testInt"),new CodePrimitiveExpression((Int32)1))
,
    // testExpression parameter to test for continuation condition.
    new CodeBinaryOperatorExpression(new 
    CodeVariableReferenceExpression("testInt"), 
    CodeBinaryOperatorType.LessThan, new CodePrimitiveExpression(
    (Int32)10)),
    // incrementStatement parameter indicates statement to execute after
    // each iteration.
    new CodeAssignStatement(new 
    CodeVariableReferenceExpression("testInt"), new
 
    CodeBinaryOperatorExpression(new 
    CodeVariableReferenceExpression("testInt"), 
    CodeBinaryOperatorType.Add, new CodePrimitiveExpression((Int32)1)))
,
    // statements parameter contains the statements to execute during
 each
    // interation of the loop.
    // Each loop iteration the value of the integer is output using
 the
    // Console.WriteLine method.
    new CodeStatement[] { new CodeExpressionStatement(new
 
    CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new
    CodeTypeReferenceExpression("Console"), "WriteLine"), 
    new CodeExpression [] { new CodeMethodInvokeExpression(new
 
    CodeVariableReferenceExpression("testInt"), "ToString", 
    new CodeExpression[] {}) })) });
    // A VJ# code generator produces the following source code for 
    // the preceeding example code:
    //     int testInt = 0;
    //     for (testInt = 1; testInt < 10; testInt = testInt + 1)
 {
    //        Console.WriteLine(System.Convert.ToString(testInt));
継承階層継承階層
System.Object
   System.CodeDom.CodeObject
     System.CodeDom.CodeStatement
      System.CodeDom.CodeIterationStatement
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

CodeIterationStatement コンストラクタ ()


CodeIterationStatement コンストラクタ (CodeStatement, CodeExpression, CodeStatement, CodeStatement[])

パラメータを指定して、CodeIterationStatement クラスの新しいインスタンスを初期化します。

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

Public Sub New ( _
    initStatement As CodeStatement, _
    testExpression As CodeExpression, _
    incrementStatement As CodeStatement, _
    ParamArray statements As CodeStatement()
 _
)
Dim initStatement As CodeStatement
Dim testExpression As CodeExpression
Dim incrementStatement As CodeStatement
Dim statements As CodeStatement()

Dim instance As New CodeIterationStatement(initStatement,
 testExpression, incrementStatement, statements)
public CodeIterationStatement (
    CodeStatement initStatement,
    CodeExpression testExpression,
    CodeStatement incrementStatement,
    params CodeStatement[] statements
)
public:
CodeIterationStatement (
    CodeStatement^ initStatement, 
    CodeExpression^ testExpression, 
    CodeStatement^ incrementStatement, 
    ... array<CodeStatement^>^ statements
)
public CodeIterationStatement (
    CodeStatement initStatement, 
    CodeExpression testExpression, 
    CodeStatement incrementStatement, 
    CodeStatement[] statements
)
public function CodeIterationStatement (
    initStatement : CodeStatement, 
    testExpression : CodeExpression, 
    incrementStatement : CodeStatement, 
    ... statements : CodeStatement[]
)

パラメータ

initStatement

ループ初期化ステートメントを格納する CodeStatement。

testExpression

終了条件をテストする対象となる式を格納する CodeExpression。

incrementStatement

循環ごとに値が増加するステートメントを格納する CodeStatement。

statements

ループ内のステートメントを格納する CodeStatement 型の配列。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CodeIterationStatement クラス
CodeIterationStatement メンバ
System.CodeDom 名前空間
CodeStatement
CodeExpression クラス

CodeIterationStatement コンストラクタ

CodeIterationStatement クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
CodeIterationStatement () CodeIterationStatement クラスの新しいインスタンスを初期化します。
CodeIterationStatement (CodeStatement, CodeExpression, CodeStatement, CodeStatement[]) パラメータを指定して、CodeIterationStatement クラスの新しいインスタンスを初期化します。
参照参照

関連項目

CodeIterationStatement クラス
CodeIterationStatement メンバ
System.CodeDom 名前空間

CodeIterationStatement プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ EndDirectives  終了ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。 ( CodeStatement から継承されます。)
パブリック プロパティ IncrementStatement ループ循環後に繰り返し呼び出されるステートメントを取得または設定します。
パブリック プロパティ InitStatement ループ初期化ステートメントを取得または設定します。
パブリック プロパティ LinePragma  コード ステートメントのある行を取得または設定します。 ( CodeStatement から継承されます。)
パブリック プロパティ StartDirectives  開始ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。 ( CodeStatement から継承されます。)
パブリック プロパティ Statements ループ内で実行されるステートメントのコレクションを取得します。
パブリック プロパティ TestExpression ループの続行条件としてテストする対象となる式を取得または設定します。
パブリック プロパティ UserData  現在のオブジェクトのユーザー定義可能なデータを取得または設定します。 ( CodeObject から継承されます。)
参照参照

関連項目

CodeIterationStatement クラス
System.CodeDom 名前空間

CodeIterationStatement メソッド


CodeIterationStatement メンバ

for ステートメント、またはループの続行条件としてテスト式を使用するステートメントのブロックを反復処理するループを表します。

CodeIterationStatement データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CodeIterationStatement オーバーロードされます。 CodeIterationStatement クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ EndDirectives  終了ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。(CodeStatement から継承されます。)
パブリック プロパティ IncrementStatement ループ循環後に繰り返し呼び出されるステートメントを取得または設定します。
パブリック プロパティ InitStatement ループ初期化ステートメントを取得または設定します。
パブリック プロパティ LinePragma  コード ステートメントのある行を取得または設定します。 (CodeStatement から継承されます。)
パブリック プロパティ StartDirectives  開始ディレクティブを含む CodeDirectiveCollection オブジェクトを取得します。(CodeStatement から継承されます。)
パブリック プロパティ Statements ループ内で実行されるステートメントのコレクションを取得します。
パブリック プロパティ TestExpression ループの続行条件としてテストする対象となる式を取得または設定します。
パブリック プロパティ UserData  現在のオブジェクトのユーザー定義可能なデータを取得または設定します。(CodeObject から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CodeIterationStatement クラス
System.CodeDom 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「CodeIterationStatement」の関連用語

CodeIterationStatementのお隣キーワード
検索ランキング

   

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



CodeIterationStatementのページの著作権

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

©2026 GRAS Group, Inc.RSS