CodeMemberMethod Klasa

Definicja

Reprezentuje deklarację dla metody typu.

public ref class CodeMemberMethod : System::CodeDom::CodeTypeMember
public class CodeMemberMethod : System.CodeDom.CodeTypeMember
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeMemberMethod : System.CodeDom.CodeTypeMember
type CodeMemberMethod = class
    inherit CodeTypeMember
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeMemberMethod = class
    inherit CodeTypeMember
Public Class CodeMemberMethod
Inherits CodeTypeMember
Dziedziczenie
CodeMemberMethod
Pochodne
Atrybuty

Przykłady

W poniższym przykładzie pokazano użycie CodeMemberMethod metody do deklarowania metody, która akceptuje parametr i zwraca wartość.

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

Uwagi

CodeMemberMethod może służyć do reprezentowania deklaracji dla metody.

Właściwość ReturnType określa typ danych zwracanej wartości metody. Właściwość Parameters zawiera parametry metody. Właściwość Statements zawiera instrukcje metody .

Konstruktory

CodeMemberMethod()

Inicjuje nowe wystąpienie klasy CodeMemberMethod.

Właściwości

Attributes

Pobiera lub ustawia atrybuty elementu członkowskiego.

(Odziedziczone po CodeTypeMember)
Comments

Pobiera kolekcję komentarzy dla elementu członkowskiego typu.

(Odziedziczone po CodeTypeMember)
CustomAttributes

Pobiera lub ustawia atrybuty niestandardowe elementu członkowskiego.

(Odziedziczone po CodeTypeMember)
EndDirectives

Pobiera dyrektywy końcowe dla elementu członkowskiego.

(Odziedziczone po CodeTypeMember)
ImplementationTypes

Pobiera typy danych interfejsów zaimplementowanych przez tę metodę, chyba że jest to implementacja metody prywatnej, która jest wskazywana przez PrivateImplementationType właściwość.

LinePragma

Pobiera lub ustawia wiersz, w którym występuje instrukcja składowa typu.

(Odziedziczone po CodeTypeMember)
Name

Pobiera lub ustawia nazwę elementu członkowskiego.

(Odziedziczone po CodeTypeMember)
Parameters

Pobiera deklaracje parametrów dla metody .

PrivateImplementationType

Pobiera lub ustawia typ danych interfejsu, jeśli jest prywatna, implementuje metodę , jeśli istnieje.

ReturnType

Pobiera lub ustawia typ danych zwracanej wartości metody.

ReturnTypeCustomAttributes

Pobiera atrybuty niestandardowe zwracanego typu metody.

StartDirectives

Pobiera dyrektywy początkowe dla elementu członkowskiego.

(Odziedziczone po CodeTypeMember)
Statements

Pobiera instrukcje w metodzie .

TypeParameters

Pobiera parametry typu dla bieżącej metody ogólnej.

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)

Zdarzenia

PopulateImplementationTypes

Zdarzenie, które zostanie podniesione po raz pierwszy podczas uzyskiwania ImplementationTypes dostępu do kolekcji.

PopulateParameters

Zdarzenie, które zostanie podniesione po raz pierwszy podczas uzyskiwania Parameters dostępu do kolekcji.

PopulateStatements

Zdarzenie, które zostanie podniesione po raz pierwszy podczas uzyskiwania Statements dostępu do kolekcji.

Dotyczy