Sdílet prostřednictvím


CodeArgumentReferenceExpression Třída

Definice

Představuje odkaz na hodnotu argumentu předaného metodě.

public ref class CodeArgumentReferenceExpression : System::CodeDom::CodeExpression
public class CodeArgumentReferenceExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeArgumentReferenceExpression : System.CodeDom.CodeExpression
type CodeArgumentReferenceExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeArgumentReferenceExpression = class
    inherit CodeExpression
Public Class CodeArgumentReferenceExpression
Inherits CodeExpression
Dědičnost
CodeArgumentReferenceExpression
Atributy

Příklady

Následující příklad kódu definuje metodu, která vyvolá Console.WriteLine výstup řetězcový parametr předaný metodě. CodeArgumentReferenceExpression Odkazuje na argument předaný metodě podle názvu parametru metody.

// Declare a method that accepts a string parameter named text.
CodeMemberMethod cmm = new CodeMemberMethod();
cmm.Parameters.Add( new CodeParameterDeclarationExpression("String", "text") );
cmm.Name = "WriteString";
cmm.ReturnType = new CodeTypeReference("System.Void");

// Create a method invoke statement to output the string passed to the method.
CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("Console"), "WriteLine", new CodeArgumentReferenceExpression("text") );

// Add the method invoke expression to the method's statements collection.
cmm.Statements.Add( cmie );

// A C# code generator produces the following source code for the preceeding example code:
//        private void WriteString(String text)
//        {
//            Console.WriteLine(text);
//        }
 ' Declare a method that accepts a string parameter named text.
 Dim cmm As New CodeMemberMethod()
 cmm.Parameters.Add(New CodeParameterDeclarationExpression("String", "text"))
 cmm.Name = "WriteString"
 cmm.ReturnType = New CodeTypeReference("System.Void")
 
 ' Create a method invoke statement to output the string passed to the method.
 Dim cmie As New CodeMethodInvokeExpression(New CodeTypeReferenceExpression("Console"), "WriteLine", New CodeArgumentReferenceExpression("text"))
 
 ' Add the method invoke expression to the method's statements collection.
 cmm.Statements.Add(cmie)

 ' A Visual Basic code generator produces the following source code for the preceeding example code:
 '		Private Sub WriteString(ByVal [text] As [String])
 '			Console.WriteLine([text])
 '		End Sub

Poznámky

CodeArgumentReferenceExpression lze použít v metodě odkazovat na hodnotu parametru, který byl předán metodě.

Vlastnost ParameterName určuje název parametru, který se má odkazovat.

Konstruktory

Name Description
CodeArgumentReferenceExpression()

Inicializuje novou instanci CodeArgumentReferenceExpression třídy.

CodeArgumentReferenceExpression(String)

Inicializuje novou instanci CodeArgumentReferenceExpression třídy pomocí zadaného názvu parametru.

Vlastnosti

Name Description
ParameterName

Získá nebo nastaví název parametru, který tento výraz odkazuje.

UserData

Získá uživatelem definovatelná data pro aktuální objekt.

(Zděděno od CodeObject)

Metody

Name Description
Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro