CodeArgumentReferenceExpression クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class CodeArgumentReferenceExpression Inherits CodeExpression
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeArgumentReferenceExpression : CodeExpression
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class CodeArgumentReferenceExpression : public CodeExpression


Console.WriteLine を呼び出して、メソッドに渡された文字列パラメータを出力するメソッドの定義を次のコード例に示します。CodeArgumentReferenceExpression は、メソッドに渡された引数をメソッドのパラメータ名によって参照します。
' 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
// 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. 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.get_Parameters().Add(new CodeParameterDeclarationExpression("String" , "text")); cmm.set_Name("WriteString"); cmm.set_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 CodeExpression[] { new CodeArgumentReferenceExpression("text")}); // Add the method invoke expression to the method's statements collection. cmm.get_Statements().Add(cmie); // A VJ# code generator produces the following source code for // the preceeding example code: // private void WriteString(String text) // { // Console.WriteLine(text); // } //WriteString

System.CodeDom.CodeObject
System.CodeDom.CodeExpression
System.CodeDom.CodeArgumentReferenceExpression


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CodeArgumentReferenceExpression クラスのページへのリンク