Прочетете на английски Редактиране

Споделяне чрез


Switch<T>.Expression Property

Definition

Gets the object to compare to the keys in the Cases collection.

C#
[System.Activities.RequiredArgument]
public System.Activities.InArgument<T> Expression { get; set; }

Property Value

The object to compare to the keys in the Cases collection.

Attributes

Examples

The following code sample demonstrates setting the Expression property of a Switch<T> activity.

C#
// 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" } }
    }
}

Remarks

The comparison occurs after the expression is evaluated.

Applies to

Продукт Версии
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1