Switch<T> Constructor

.NET Framework (current version)
 

Creates a new instance of the Switch<T> class.

Namespace:   System.Activities.Statements
Assembly:  System.Activities (in System.Activities.dll)

NameDescription
System_CAPS_pubmethodSwitch<T>()

Creates a new instance of the Switch<T> class.

System_CAPS_pubmethodSwitch<T>(Activity<T>)

Creates a new instance of the Switch<T> class with the specified expression.

System_CAPS_pubmethodSwitch<T>(Expression<Func<ActivityContext, T>>)

Creates a new instance of the Switch<T> class with the specified expression.

System_CAPS_pubmethodSwitch<T>(InArgument<T>)

Creates a new instance of the Switch<T> class with the specified expression.

The following code sample demonstrates creating a Switch<T> activity. This example is from the Using Procedural Activities sample.

// check if the number is ok...
new Switch<int>()
{
    DisplayName = "Verify Value from User",
    Expression = ExpressionServices.Convert<int>( env => numberFromUser.Get(env).CompareTo(numberToGuess.Get(env)) ),
    Cases = 
    {
        { 0, new Assign<bool>()
            {
                To = new OutArgument<bool>(finished),
                Value = true
            }
        },
        {  1, new WriteLine() { Text = "    Try a lower number number..." } }, 
        { -1, new WriteLine() { Text = "    Try a higher number" } }
    }
}
Return to top
Show: