Expression Property
Collapse the table of content
Expand the table of content

Switch<T>.Expression Property

.NET Framework (current version)
 

Gets the object to compare to the keys in the P:System.Activities.Statements.Switch.Cases collection.

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

[RequiredArgumentAttribute]
public InArgument<T> Expression { get; set; }

Property Value

Type: System.Activities.InArgument<T>

The object to compare to the keys in the P:System.Activities.Statements.Switch.Cases collection.

The comparison occurs after the expression is evaluated.

The following code sample demonstrates setting the Expression property of 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" } }
    }
}

.NET Framework
Available since 4.0
Return to top
Show:
© 2016 Microsoft