System.CodeDom.CodeConditionStatement Class

Assembly: System.dll
Namespace: System.CodeDom
Summary
Represents a conditional branch statement, typically represented as an if statement.
C# Syntax:
[Serializable]
public class CodeConditionStatement : CodeStatement
Remarks
CodeConditionStatement can be used to represent code that consists of a conditional expression, a collection of statements to execute if the conditional expression evaluates to true, and an optional collection of statements to execute if the conditional expression evaluates to false. A CodeConditionStatement is represented in many languages as an if statement.
See also:
System.CodeDom Namespace

System.CodeDom.CodeConditionStatement Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the CodeConditionStatement class.
ctor #2 Overloaded:
.ctor(CodeExpression condition, params CodeStatement[] trueStatements)

Initializes a new instance of the CodeConditionStatement class using the specified condition and statements.
ctor #3 Overloaded:
.ctor(CodeExpression condition, CodeStatement[] trueStatements, CodeStatement[] falseStatements)

Initializes a new instance of the CodeConditionStatement class using the specified condition and statements.
Public Properties
Condition Read-write

Gets or sets the conditional expression to test.
FalseStatements Read-only

Gets the collection of statements to execute if the conditional expression evaluates to false.
LinePragma
(inherited from System.CodeDom.CodeStatement)
Read-write

See base class member description: System.CodeDom.CodeStatement.LinePragma


Gets or sets the line the statement occurs on.
TrueStatements Read-only

Gets the collection of statements to execute if the conditional expression evaluates to true.
UserData
(inherited from System.CodeDom.CodeObject)
Read-only

See base class member description: System.CodeDom.CodeObject.UserData


Gets or sets the user-definable data for the current object.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.CodeDom.CodeConditionStatement Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CodeConditionStatement class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public CodeConditionStatement();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CodeConditionStatement class using the specified condition and statements.
C# Syntax:
public CodeConditionStatement(
   CodeExpression condition,
   params CodeStatement[] trueStatements
);
Parameters:

condition

A CodeExpression that indicates the condition to test for.

trueStatements

An array of type CodeStatement containing the statements to execute if the condition is true.

See also:
CodeExpression | CodeStatement

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the CodeConditionStatement class using the specified condition and statements.
C# Syntax:
public CodeConditionStatement(
   CodeExpression condition,
   CodeStatement[] trueStatements,
   CodeStatement[] falseStatements
);
Parameters:

condition

A CodeExpression that indicates the condition to test for.

trueStatements

An array of type CodeStatement containing the statements to execute if the condition is true.

falseStatements

An array of type CodeStatement containing the statements to execute if the condition is false.

See also:
CodeExpression | CodeStatement

Return to top


Property: Condition (read-write)
Summary
Gets or sets the conditional expression to test.
C# Syntax:
public CodeExpression Condition {get; set;}
Remarks
If this conditional expression evaluates to true, the code contained within the CodeConditionStatement.TrueStatements collection will be executed. If this conditional expression evaluates to false, any code contained within the CodeConditionStatement.FalseStatements collection will be executed.
See also:
CodeExpression

Return to top


Property: FalseStatements (read-only)
Summary
Gets the collection of statements to execute if the conditional expression evaluates to false.
C# Syntax:
public CodeStatementCollection FalseStatements {get;}
See also:
CodeStatementCollection

Return to top


Property: LinePragma (read-write)
Inherited
See base class member description: System.CodeDom.CodeStatement.LinePragma

Summary
Gets or sets the line the statement occurs on.
C# Syntax:
public CodeLinePragma LinePragma {get; set;}
Remarks
This property indicates the location of the statement.
See also:
CodeLinePragma

Return to top


Property: TrueStatements (read-only)
Summary
Gets the collection of statements to execute if the conditional expression evaluates to true.
C# Syntax:
public CodeStatementCollection TrueStatements {get;}
See also:
CodeStatementCollection

Return to top


Property: UserData (read-only)
Inherited
See base class member description: System.CodeDom.CodeObject.UserData

Summary
Gets or sets the user-definable data for the current object.
C# Syntax:
public IDictionary UserData {get;}
Remarks


Notes to inheritors: An inheritor can design the way this user data is stored, retrieved, and used.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~CodeConditionStatement();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.