Switch<T>.Cases 屬性

定義

表示可能之執行路徑的字典。 每個項目都會包含當運算式結果符合索引鍵時執行的索引鍵與活動。

public:
 property System::Collections::Generic::IDictionary<T, System::Activities::Activity ^> ^ Cases { System::Collections::Generic::IDictionary<T, System::Activities::Activity ^> ^ get(); };
public System.Collections.Generic.IDictionary<T,System.Activities.Activity> Cases { get; }
member this.Cases : System.Collections.Generic.IDictionary<'T, System.Activities.Activity>
Public ReadOnly Property Cases As IDictionary(Of T, Activity)

屬性值

執行路徑。

範例

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

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

備註

當活動執行時,執行的案例是其索引鍵符合 Expression 屬性的第一個案例。

適用於