CodeMethodReturnStatement Osztály

Definíció

Visszatérési érték utasítást jelöl.

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
Öröklődés
CodeMethodReturnStatement
Attribútumok

Példák

Az alábbi példa azt mutatja be, hogy az a CodeMethodReturnStatement metódusból származó értéket ad vissza.

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

Megjegyzések

CodeMethodReturnStatement a visszatérési érték kimutatásának megjelenítésére használható. A Expression tulajdonság a visszaadandó értéket adja meg.

Konstruktorok

Name Description
CodeMethodReturnStatement()

Inicializálja a CodeMethodReturnStatement osztály új példányát.

CodeMethodReturnStatement(CodeExpression)

Inicializálja az osztály új példányát CodeMethodReturnStatement a megadott kifejezéssel.

Tulajdonságok

Name Description
EndDirectives

Lekéri a CodeDirectiveCollection végfelhasználói irányelveket tartalmazó objektumot.

(Öröklődés forrása CodeStatement)
Expression

Lekéri vagy beállítja a visszatérési értéket.

LinePragma

Lekéri vagy beállítja azt a sort, amelyen a kódutasítás történik.

(Öröklődés forrása CodeStatement)
StartDirectives

Lekéri a CodeDirectiveCollection kezdő irányelveket tartalmazó objektumot.

(Öröklődés forrása CodeStatement)
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)

A következőre érvényes: