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

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

CodeConditionStatement を使用して、条件式、条件式が true と評価される場合に実行されるステートメントのコレクション、および条件式が false と評価される場合に実行されるオプションのステートメントのコレクションで構成されるコードを表すことができます。多くの言語では、CodeConditionStatement は if ステートメントとして生成されます。
Condition プロパティは、テストする対象となる式を示します。TrueStatements プロパティには、テストする式が true と評価された場合に実行されるステートメントが含まれています。FalseStatements プロパティには、テストする式が false と評価された場合に実行されるステートメントが含まれています。

CodeConditionStatement を使用して、else ブロックのある if ステートメントを表す例を次に示します。
' Create a CodeConditionStatement that tests a boolean value named boolean. Dim conditionalStatement As New CodeConditionStatement( _ New CodeVariableReferenceExpression("boolean"), _ New CodeStatement() {New CodeCommentStatement("If condition is true, execute these statements.")}, _ New CodeStatement() {New CodeCommentStatement("Else block. If condition is false, execute these statements.")}) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' If [boolean] Then ' 'If condition is true, execute these statements. ' Else ' 'Else block. If condition is false, execute these statements.
// Create a CodeConditionStatement that tests a boolean value named boolean. CodeConditionStatement conditionalStatement = new CodeConditionStatement( // The condition to test. new CodeVariableReferenceExpression("boolean"), // The statements to execute if the condition evaluates to true. new CodeStatement[] { new CodeCommentStatement("If condition is true, execute these statements.") }, // The statements to execute if the condition evalues to false. new CodeStatement[] { new CodeCommentStatement("Else block. If condition is false, execute these statements.") } ); // A C# code generator produces the following source code for the preceeding example code: // if (boolean) // { // // If condition is true, execute these statements. // } // else { // // Else block. If condition is false, execute these statements. // }
// Create a CodeConditionStatement that tests a boolean value named boolean. array<CodeStatement^>^temp0 = {gcnew CodeCommentStatement( "If condition is true, execute these statements." )}; array<CodeStatement^>^temp1 = {gcnew CodeCommentStatement( "Else block. If condition is false, execute these statements." )}; // The statements to execute if the condition evalues to false. CodeConditionStatement^ conditionalStatement = gcnew CodeConditionStatement( gcnew CodeVariableReferenceExpression( "boolean" ),temp0,temp1 ); // A C# code generator produces the following source code for the preceeding example code: // if (boolean) // { // // If condition is true, execute these statements. // } // else { // // Else block. If condition is false, execute these statements. // }
// Create a CodeConditionStatement that tests a boolean // value named boolean. CodeConditionStatement conditionalStatement = new CodeConditionStatement( // The condition to test. new CodeVariableReferenceExpression("boolean"), // The statements to execute if the condition evaluates to true. new CodeStatement[] { new CodeCommentStatement("If condition is true," + "execute these statements.") }, // The statements to execute if the condition evalues to false. new CodeStatement[] { new CodeCommentStatement("Else block. If " + "condition is false, execute these statements.") }); // A VJ# code generator produces the following source code for the // preceeding example code: // if (boolean) { // // If condition is true, execute these statements. // } // else { // // Else block. If condition is false, execute these statements. // }

System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeConditionStatement


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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