CodeArgumentReferenceExpression Klasa

Definicja

Reprezentuje odwołanie do wartości argumentu przekazanego do metody.

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
Dziedziczenie
CodeArgumentReferenceExpression
Atrybuty

Przykłady

Poniższy przykładowy kod definiuje metodę, która wywołuje w Console.WriteLine celu wyprowadzenia parametru ciągu przekazanego do metody. Odwołuje CodeArgumentReferenceExpression się do argumentu przekazanego do metody według nazwy parametru metody.

// Declare a method that accepts a string parameter named text.
CodeMemberMethod^ cmm = gcnew CodeMemberMethod;
cmm->Parameters->Add( gcnew CodeParameterDeclarationExpression( "String","text" ) );
cmm->Name = "WriteString";
cmm->ReturnType = gcnew CodeTypeReference( "System::Void" );
array<CodeExpression^>^ce = {gcnew CodeArgumentReferenceExpression( "test1" )};

// Create a method invoke statement to output the string passed to the method.
CodeMethodInvokeExpression^ cmie = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "Console" ),"WriteLine",ce );

// 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.
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

Uwagi

CodeArgumentReferenceExpression można użyć w metodzie , aby odwoływać się do wartości parametru, który został przekazany do metody.

Właściwość ParameterName określa nazwę parametru do odwołania.

Konstruktory

CodeArgumentReferenceExpression()

Inicjuje nowe wystąpienie klasy CodeArgumentReferenceExpression.

CodeArgumentReferenceExpression(String)

Inicjuje CodeArgumentReferenceExpression nowe wystąpienie klasy przy użyciu określonej nazwy parametru.

Właściwości

ParameterName

Pobiera lub ustawia nazwę parametru, do których odwołuje się to wyrażenie.

UserData

Pobiera dane, które można definiować przez użytkownika dla bieżącego obiektu.

(Odziedziczone po CodeObject)

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy