FieldDirection Výčet
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Definuje identifikátory používané k označení směru deklarace parametrů a argumentů.
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
- Dědičnost
- Atributy
Pole
| Name | Hodnota | Description |
|---|---|---|
| In | 0 | Příchozí pole. |
| Out | 1 | Odchozí pole. |
| Ref | 2 | Pole podle odkazu. |
Příklady
Následující příklad ukazuje použití FieldDirection k označení typů směr pole parametrů metody v deklaraci metody.
// 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
Poznámky
FieldDirection umožňuje předávání argumentů funkcí odkazem nebo pomocí příchozích nebo odchozích parametrů.