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

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

CodeMemberMethod を使用して、メソッドの宣言を表すことができます。
ReturnType プロパティは、メソッドの戻り値のデータ型を指定します。Parameters プロパティには、メソッドのパラメータを格納します。Statements プロパティには、メソッドのステートメントを格納します。

CodeMemberMethod を使用して、パラメータを受け取り、値を返すメソッドを宣言する例を次に示します。
' Defines a method that returns a string passed to it. Dim method1 As New CodeMemberMethod() method1.Name = "ReturnString" method1.ReturnType = New CodeTypeReference("System.String") method1.Parameters.Add(New CodeParameterDeclarationExpression("System.String", "text")) method1.Statements.Add(New CodeMethodReturnStatement(New CodeArgumentReferenceExpression("text"))) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' Private Function ReturnString(ByVal [text] As String) As String ' Return [Text] ' End Function
// Defines a method that returns a string passed to it. CodeMemberMethod method1 = new CodeMemberMethod(); method1.Name = "ReturnString"; method1.ReturnType = new CodeTypeReference("System.String"); method1.Parameters.Add( new CodeParameterDeclarationExpression("System.String", "text") ); method1.Statements.Add( new CodeMethodReturnStatement( new CodeArgumentReferenceExpression("text") ) ); // A C# code generator produces the following source code for the preceeding example code: // private string ReturnString(string text) // { // return text; // }
// Defines a method that returns a string passed to it. CodeMemberMethod^ method1 = gcnew CodeMemberMethod; method1->Name = "ReturnString"; method1->ReturnType = gcnew CodeTypeReference( "System.String" ); method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.String","text" ) ); method1->Statements->Add( gcnew CodeMethodReturnStatement( gcnew CodeArgumentReferenceExpression( "text" ) ) ); // A C# code generator produces the following source code for the preceeding example code: // private string ReturnString(string text) // { // return text; // }
// Defines a method that returns a string passed to it. CodeMemberMethod method1 = new CodeMemberMethod(); method1.set_Name("ReturnString"); method1.set_ReturnType(new CodeTypeReference("System.String")); method1.get_Parameters().Add(new CodeParameterDeclarationExpression( "System.String", "text")); method1.get_Statements().Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression("text"))); // A VJ# code generator produces the following source code for // the preceeding example code: // private String ReturnString(String text) // { // return text; // } //ReturnString

System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeMemberMethod
System.CodeDom.CodeConstructor
System.CodeDom.CodeEntryPointMethod
System.CodeDom.CodeTypeConstructor


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


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