FieldDirection Enumeration
TOC
Collapse the table of content
Expand the table of content

FieldDirection Enumeration

Defines identifiers used to indicate the direction of parameter and argument declarations.

[Visual Basic]
<Serializable>
<ComVisible(True)>
Public Enum FieldDirection
[C#]
[Serializable]
[ComVisible(true)]
public enum FieldDirection
[C++]
[Serializable]
[ComVisible(true)]
__value public enum FieldDirection
[JScript]
public
   Serializable
 ComVisible(true)
enum FieldDirection

Remarks

FieldDirection allows for passing arguments to functions by reference, or using incoming or outgoing parameters.

Members

Member name Description
In An incoming field.
Out An outgoing field.
Ref A field by reference.

Example

[Visual Basic, C#, C++] The following example demonstrates use of FieldDirection to indicate the field direction types of the parameters of a method in a method declaration.

[Visual Basic] 
' 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

[C#] 
// 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) {
//        }

[C++] 
// Declares a method.
CodeMemberMethod* method1 = new CodeMemberMethod();
method1->Name = S"TestMethod";

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

// Declares a Int32 parameter passed by incoming field.
CodeParameterDeclarationExpression* param2 = new CodeParameterDeclarationExpression(S"System.Int32", S"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) {
//        }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

System.CodeDom Namespace | CodeParameterDeclarationExpression | CodeDirectionExpression

Show:
© 2016 Microsoft