共用方式為


Switch<T>.Expression 屬性

定義

取得與 Cases 集合中索引鍵比較的物件。

public:
 property System::Activities::InArgument<T> ^ Expression { System::Activities::InArgument<T> ^ get(); void set(System::Activities::InArgument<T> ^ value); };
[System.Activities.RequiredArgument]
public System.Activities.InArgument<T> Expression { get; set; }
[<System.Activities.RequiredArgument>]
member this.Expression : System.Activities.InArgument<'T> with get, set
Public Property Expression As InArgument(Of T)

屬性值

Cases 集合中索引鍵比較的物件。

屬性

範例

下列程式碼範例將示範如何設定 Switch<T> 活動的 Expression 屬性。

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

備註

評估運算式後發生的比較。

適用於