Delen via


Using the IfElseActivity Activity

You use the IfElseActivity activity to conditionally execute one of several alternative IfElseBranchActivity branches. You place a condition on each IfElseBranchActivity activity. If the condition evaluates to true, the activities that are contained in the IfElseBranchActivity activity are executed; otherwise, the next IfElseBranchActivity condition is evaluated, and so on. You do not have to put a condition on the last IfElseBranchActivity activity because it is treated as the Else branch. For more information about conditions, see Using Conditions in Workflows.

You can add as many IfElseBranchActivity activities as you want to an IfElseActivity activity, and you can add as many activities as you want to each IfElseBranchActivity activity. For more information about the IfElseBranchActivity activity, see Using the IfElseBranchActivity Activity.

Note

Only the first IfElseBranchActivity of an IfElseActivity activity that evaluates to true will be executed.

For more information, see the IfElseActivity and IfElseBranchActivity classes of the System.Workflow.Activities namespace in the Windows Workflow Foundation Class Library reference.

For code samples that demonstrate how to use the IfElseActivity activity, see Simple Sequential Workflow and IfElse With Rules.

See Also

Reference

IfElseActivity
IfElseBranchActivity

Concepts

Using Conditions in Workflows
Using the IfElseBranchActivity Activity
Rules and Conditions Overview

Other Resources

IfElse with Rules Sample
Simple Sequential Workflow Sample
Windows Workflow Foundation Activities