FieldDirection 枚举

定义

定义用于指示参数的方向和参数声明的标识符。Defines identifiers used to indicate the direction of parameter and argument declarations.

public enum class FieldDirection
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum FieldDirection
type FieldDirection = 
Public Enum FieldDirection
继承
FieldDirection
属性

字段

In 0

传入字段。An incoming field.

Out 1

输出字段。An outgoing field.

Ref 2

传址方式字段。A field by reference.

示例

下面的示例演示FieldDirection如何使用来指示方法声明中方法的参数的字段方向类型。The following example demonstrates use of FieldDirection to indicate the field direction types of the parameters of a method in a method declaration.

// Declares a method.
CodeMemberMethod^ method1 = gcnew CodeMemberMethod;
method1->Name = "TestMethod";

// Declares a string parameter passed by reference.
CodeParameterDeclarationExpression^ param1 = gcnew CodeParameterDeclarationExpression( "System.String","stringParam" );
param1->Direction = FieldDirection::Ref;
method1->Parameters->Add( param1 );

// Declares a Int32 parameter passed by incoming field.
CodeParameterDeclarationExpression^ param2 = gcnew CodeParameterDeclarationExpression( "System.Int32","intParam" );
param2->Direction = FieldDirection::Out;
method1->Parameters->Add( param2 );

// A C# code generator produces the following source code for the preceeding example code:
//        private void TestMethod(ref string stringParam, out int intParam) {
//        }
// Declares a method.
CodeMemberMethod method1 = new CodeMemberMethod();
method1.Name = "TestMethod";

// Declares a string parameter passed by reference.
CodeParameterDeclarationExpression param1 = new CodeParameterDeclarationExpression("System.String", "stringParam");
param1.Direction = FieldDirection.Ref;
method1.Parameters.Add(param1);

// Declares a Int32 parameter passed by incoming field.
CodeParameterDeclarationExpression param2 = new CodeParameterDeclarationExpression("System.Int32", "intParam");
param2.Direction = FieldDirection.Out;
method1.Parameters.Add(param2);

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

//        private void TestMethod(ref string stringParam, out int intParam) {
//        }
           ' Declares a method.
           Dim method1 As New CodeMemberMethod()
           method1.Name = "TestMethod"

           ' Declares a string parameter passed by reference.
           Dim param1 As New CodeParameterDeclarationExpression("System.String", "stringParam")
           param1.Direction = FieldDirection.Ref
           method1.Parameters.Add(param1)

           ' Declares a Int32 parameter passed by incoming field.
           Dim param2 As New CodeParameterDeclarationExpression("System.Int32", "intParam")
           param2.Direction = FieldDirection.Out
           method1.Parameters.Add(param2)

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

           '	 Private Sub TestMethod(ByRef stringParam As String, ByRef intParam As Integer)
           '    End Sub

注解

FieldDirection允许通过引用或使用传入或传出参数将参数传递给函数。FieldDirection allows for passing arguments to functions by reference, or using incoming or outgoing parameters.

适用于

另请参阅