Variable.Expression 屬性

定義

取得或設定變數中包含的運算式。

public:
 property System::String ^ Expression { System::String ^ get(); void set(System::String ^ value); };
[Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "ExpressionDesc")]
public string Expression { get; set; }
[<Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "ExpressionDesc")>]
member this.Expression : string with get, set
Public Property Expression As String

屬性值

String

包含運算式的字串。

屬性

範例

下列範例會設定旗標, EvaluateAsExpression 以顯示變數包含運算式,然後可以使用 Expression 屬性。

static void Main(string[] args)  
    {  
        Package p = new Package();  
        p.Variables.Add("x", false, "", 1);  
        Variable v = p.Variables.Add("y", false, "", 1);  
        v.Expression = "@x + 10";  
        v.EvaluateAsExpression = true;  
        if (v.Value.ToString() == "11")  
            Console.WriteLine("Value was 11");  
        else  
            Console.WriteLine("Value was not 11");  
    }  
Shared  Sub Main(ByVal args() As String)  
        Dim p As Package =  New Package()   
        p.Variables.Add("x", False, "", 1)  
        Dim v As Variable =  p.Variables.Add("y",False,"",1)   
        v.Expression = "@x + 10"  
        v.EvaluateAsExpression = True  
        If v.Value.ToString() = "11" Then  
            Console.WriteLine("Value was 11")  
        Else   
            Console.WriteLine("Value was not 11")  
        End If  
End Sub  

範例輸出:

值為11

備註

Expression只有當屬性設定為時,此方法才會傳回在 value 屬性中輸入的運算式 EvaluateAsExpression true ,否則會傳回空字串 false

適用於