Share via


CodeConditionStatement Sınıf

Tanım

Genellikle bir deyim olarak if temsil edilen koşullu dal deyimini temsil eder.

public ref class CodeConditionStatement : System::CodeDom::CodeStatement
public class CodeConditionStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeConditionStatement : System.CodeDom.CodeStatement
type CodeConditionStatement = class
    inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeConditionStatement = class
    inherit CodeStatement
Public Class CodeConditionStatement
Inherits CodeStatement
Devralma
CodeConditionStatement
Öznitelikler

Örnekler

Bu örnekte, bir CodeConditionStatement bloğu olan bir if deyimi temsil etmek için kullanma gösterilmektedir else .

// 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 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.
 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.

Açıklamalar

CodeConditionStatementkoşullu ifadeden oluşan kodu, koşullu ifade olarak değerlendirilirse yürütülecek deyim koleksiyonunu ve koşullu ifade olarak değerlendirilirse truefalseyürütülecek isteğe bağlı deyim koleksiyonunu göstermek için kullanılabilir. bir CodeConditionStatement deyimi olarak if birçok dilde oluşturulur.

Condition özelliği, test etmek için ifadeyi gösterir. özelliği, TrueStatements test edilen ifade olarak değerlendirilirse yürütülecek deyimleri trueiçerir. özelliği, FalseStatements test edilen ifade olarak değerlendirilirse yürütülecek deyimleri falseiçerir.

Oluşturucular

CodeConditionStatement()

CodeConditionStatement sınıfının yeni bir örneğini başlatır.

CodeConditionStatement(CodeExpression, CodeStatement[])

Belirtilen koşulu ve deyimleri kullanarak sınıfının yeni bir örneğini CodeConditionStatement başlatır.

CodeConditionStatement(CodeExpression, CodeStatement[], CodeStatement[])

Belirtilen koşulu ve deyimleri kullanarak sınıfının yeni bir örneğini CodeConditionStatement başlatır.

Özellikler

Condition

veya değerini değerlendirmek true için ifadeyi alır veya falseayarlar.

EndDirectives

Bitiş yönergelerini içeren bir CodeDirectiveCollection nesnesi alır.

(Devralındığı yer: CodeStatement)
FalseStatements

Koşullu ifade olarak değerlendirilirse yürütülecek deyim koleksiyonunu falsealır.

LinePragma

Kod deyiminin oluştuğu satırı alır veya ayarlar.

(Devralındığı yer: CodeStatement)
StartDirectives

Başlangıç yönergelerini içeren bir CodeDirectiveCollection nesnesi alır.

(Devralındığı yer: CodeStatement)
TrueStatements

Koşullu ifade olarak değerlendirilirse yürütülecek deyim koleksiyonunu truealır.

UserData

Geçerli nesne için kullanıcı tarafından tanımlanabilir verileri alır.

(Devralındığı yer: CodeObject)

Yöntemler

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır