CodeDirectionExpression Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Represents an expression used as a method invoke parameter along with a reference direction indicator.

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


public class CodeDirectionExpression : CodeExpression


Initializes a new instance of the CodeDirectionExpression class.

System_CAPS_pubmethodCodeDirectionExpression(FieldDirection, CodeExpression)

Initializes a new instance of the CodeDirectionExpression class using the specified field direction and expression.


Gets or sets the field direction for this direction expression.


Gets or sets the code expression to represent.


Gets the user-definable data for the current object.(Inherited from CodeObject.)


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

CodeDirectionExpression can represent a parameter passed to a method and the reference direction of the parameter.

The Expression property indicates the expression to qualify with a direction. The Direction property indicates the direction of the parameter using one of the FieldDirection enumeration values.


CodeDirectionExpression is intended to be used as a method invoke parameter, and should not be used when declaring methods.

The following example demonstrates use of a CodeDirectionExpression to specify a field direction modifier for an expression to pass as a method parameter.

// Declares a parameter passed by reference using a CodeDirectionExpression.
CodeDirectionExpression param1 = new CodeDirectionExpression(FieldDirection.Ref, new CodeFieldReferenceExpression( new CodeThisReferenceExpression(), "TestParameter" ));
// Invokes a method on this named TestMethod using the direction expression as a parameter.
CodeMethodInvokeExpression methodInvoke1 = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "TestMethod", param1 );

// A C# code generator produces the following source code for the preceeding example code:    

//        this.TestMethod(ref TestParameter);

.NET Framework
Available since 1.1

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

Return to top