CodeDirectionExpression 类

定义

表示用作方法调用参数及引用方向指示器的表达式。Represents an expression used as a method invoke parameter along with a reference direction indicator.

public ref class CodeDirectionExpression : System::CodeDom::CodeExpression
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeDirectionExpression : System.CodeDom.CodeExpression
type CodeDirectionExpression = class
    inherit CodeExpression
Public Class CodeDirectionExpression
Inherits CodeExpression
继承
CodeDirectionExpression
属性

示例

下面的示例演示CodeDirectionExpression如何使用来指定要作为方法参数传递的表达式的字段方向修饰符。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.
array<CodeDirectionExpression^>^param1 = {gcnew CodeDirectionExpression( FieldDirection::Ref,gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"TestParameter" ) )};

// Invokes a method on this named TestMethod using the direction expression as a parameter.
CodeMethodInvokeExpression^ methodInvoke1 = gcnew CodeMethodInvokeExpression( gcnew CodeThisReferenceExpression,"TestMethod",param1 );

// A C# code generator produces the following source code for the preceeding example code:
//        this.TestMethod(ref TestParameter);
// 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);
' Declares a parameter passed by reference using a CodeDirectionExpression.
Dim param1 As New CodeDirectionExpression(FieldDirection.Ref, New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "TestParameter"))
' Invokes a method on this named TestMethod using the direction expression as a parameter.
Dim methodInvoke1 As New CodeMethodInvokeExpression(New CodeThisReferenceExpression(), "TestMethod", param1)

' A Visual Basic code generator produces the following source code for the preceeding example code:	

'      Me.TestMethod("TestParameter")

注解

CodeDirectionExpression可以表示传递给方法的参数和参数的引用方向。CodeDirectionExpression can represent a parameter passed to a method and the reference direction of the parameter.

Expression属性指示向方向限定的表达式。The Expression property indicates the expression to qualify with a direction. 属性使用一个FieldDirection枚举值指示参数的方向。 DirectionThe Direction property indicates the direction of the parameter using one of the FieldDirection enumeration values.

备注

CodeDirectionExpression旨在用作方法调用参数, 不应在声明方法时使用。CodeDirectionExpression is intended to be used as a method invoke parameter, and should not be used when declaring methods.

构造函数

CodeDirectionExpression()

初始化 CodeDirectionExpression 类的新实例。Initializes a new instance of the CodeDirectionExpression class.

CodeDirectionExpression(FieldDirection, CodeExpression)

使用指定的字段方向和表达式初始化 CodeDirectionExpression 类的新实例。Initializes a new instance of the CodeDirectionExpression class using the specified field direction and expression.

属性

Direction

获取或设置此方向表达式的字段方向。Gets or sets the field direction for this direction expression.

Expression

获取或设置要表示的代码表达式。Gets or sets the code expression to represent.

UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于