FieldDirection Enum
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines identifiers used to indicate the direction of parameter and argument declarations.
public enum class FieldDirection
public enum FieldDirection
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum FieldDirection
type FieldDirection =
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type FieldDirection =
Public Enum FieldDirection
- Inheritance
- Attributes
Name | Value | Description |
---|---|---|
In | 0 | An incoming field. |
Out | 1 | An outgoing field. |
Ref | 2 | A field by reference. |
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 allows for passing arguments to functions by reference, or using incoming or outgoing parameters.
Produkt | Versions |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET er et åben kildekode projekt. Vælg et link for at give feedback: