Export (0) Print
Expand All

Variable<T> Class

Represents a variable in a workflow.

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

public sealed class Variable<T> : Variable

Type Parameters


The Type of the Variable<T>.

The Variable<T> type exposes the following members.

Public methodVariable<T>()Initializes a new instance of the Variable<T> class.
Public methodVariable<T>(Expression<Func<ActivityContext, T>>)Initializes a new instance of the Variable<T> class with the default expression.
Public methodVariable<T>(String)Initializes a new instance of the Variable<T> class with the variable name.
Public methodVariable<T>(String, Expression<Func<ActivityContext, T>>)Initializes a new instance of the Variable<T> class with the variable name and default expression.
Public methodVariable<T>(String, T)Initializes a new instance of the Variable<T> class with the variable name and default value.

Public propertyDefaultGets or sets the Activity<TResult> that represents the default value for this Variable<T>.
Public propertyModifiersGets or sets the VariableModifiers value for this Variable. (Inherited from Variable.)
Public propertyNameGets or sets the name of the Variable. (Inherited from Variable.)
Public propertyTypeGets or sets the type of the LocationReference. (Inherited from LocationReference.)

Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetGets the value of the variable using the specified ActivityContext.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLocationReturns the Location<T> of the variable.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSet(ActivityContext, Object)Sets the value of the Variable using the specified ActivityContext. (Inherited from Variable.)
Public methodSet(ActivityContext, T)Sets the value of the variable.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

In this example, a Variable<T> is used to hold a message string. This message is written to the console window by a WriteLine activity.

Variable<string> msg = 
    new Variable<string>() { Default = "Hello World!" };

Activity wf = new Sequence()
    Variables = 
    Activities =
        new WriteLine()
            Text = msg

.NET Framework

Supported in: 4.5.3, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2014 Microsoft