CodeArgumentReferenceExpression Osztály
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Egy metódusnak átadott argumentum értékére mutató hivatkozást jelöl.
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
- Öröklődés
- Attribútumok
Példák
Az alábbi példakód egy metódust határoz meg, amely meghívja Console.WriteLine a metódusnak átadott sztringparaméter kimenetét. A CodeArgumentReferenceExpression metódus paraméternév alapján átadott argumentumra hivatkozik.
// 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
Megjegyzések
CodeArgumentReferenceExpression egy metódusban a metódusnak átadott paraméter értékére hivatkozhat.
A ParameterName tulajdonság megadja a hivatkozni kívánt paraméter nevét.
Konstruktorok
| Name | Description |
|---|---|
| CodeArgumentReferenceExpression() |
Inicializálja a CodeArgumentReferenceExpression osztály új példányát. |
| CodeArgumentReferenceExpression(String) |
Inicializálja az osztály új példányát CodeArgumentReferenceExpression a megadott paraméternév használatával. |
Tulajdonságok
| Name | Description |
|---|---|
| ParameterName |
Lekéri vagy beállítja annak a paraméternek a nevét, amelyre a kifejezés hivatkozik. |
| UserData |
Lekéri az aktuális objektum felhasználó által definiálható adatait. (Öröklődés forrása CodeObject) |
Metódusok
| Name | Description |
|---|---|
| Equals(Object) |
Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal. (Öröklődés forrása Object) |
| GetHashCode() |
Ez az alapértelmezett kivonatoló függvény. (Öröklődés forrása Object) |
| GetType() |
Lekéri az Type aktuális példányt. (Öröklődés forrása Object) |
| MemberwiseClone() |
Az aktuális Objectpéldány sekély másolatát hozza létre. (Öröklődés forrása Object) |
| ToString() |
Az aktuális objektumot jelképező sztringet ad vissza. (Öröklődés forrása Object) |