Freigeben über


CodeMethodReturnStatement Klasse

Definition

Stellt eine Rückgabewert-Anweisung dar.

public ref class CodeMethodReturnStatement : System::CodeDom::CodeStatement
public class CodeMethodReturnStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeMethodReturnStatement : System.CodeDom.CodeStatement
type CodeMethodReturnStatement = class
    inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeMethodReturnStatement = class
    inherit CodeStatement
Public Class CodeMethodReturnStatement
Inherits CodeStatement
Vererbung
CodeMethodReturnStatement
Attribute

Beispiele

Im folgenden Beispiel wird die Verwendung eines CodeMethodReturnStatement Werts aus einer Methode veranschaulicht.

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

Hinweise

CodeMethodReturnStatement kann verwendet werden, um eine Rückgabewert-Anweisung darzustellen. Die Expression Eigenschaft gibt den zurückzugebenden Wert an.

Konstruktoren

Name Beschreibung
CodeMethodReturnStatement()

Initialisiert eine neue Instanz der CodeMethodReturnStatement-Klasse.

CodeMethodReturnStatement(CodeExpression)

Initialisiert eine neue Instanz der CodeMethodReturnStatement Klasse mithilfe des angegebenen Ausdrucks.

Eigenschaften

Name Beschreibung
EndDirectives

Ruft ein CodeDirectiveCollection Objekt ab, das Enddirektiven enthält.

(Geerbt von CodeStatement)
Expression

Dient zum Abrufen oder Festlegen des Rückgabewerts.

LinePragma

Ruft die Zeile ab, in der die Code-Anweisung auftritt, oder legt sie fest.

(Geerbt von CodeStatement)
StartDirectives

Ruft ein CodeDirectiveCollection Objekt ab, das Startdirektiven enthält.

(Geerbt von CodeStatement)
UserData

Ruft die vom Benutzer definierbaren Daten für das aktuelle Objekt ab.

(Geerbt von CodeObject)

Methoden

Name Beschreibung
Equals(Object)

Bestimmt, ob das angegebene Objekt dem aktuellen Objekt entspricht.

(Geerbt von Object)
GetHashCode()

Dient als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft die Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie der aktuellen Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für: