Sdílet prostřednictvím


CodeMethodReturnStatement Třída

Definice

Představuje návratový příkaz hodnoty.

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
Dědičnost
CodeMethodReturnStatement
Atributy

Příklady

Následující příklad ukazuje použití k CodeMethodReturnStatement vrácení hodnoty z metody.

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

Poznámky

CodeMethodReturnStatement lze použít k reprezentaci návratového příkazu hodnoty. Vlastnost Expression určuje hodnotu, která se má vrátit.

Konstruktory

Name Description
CodeMethodReturnStatement()

Inicializuje novou instanci CodeMethodReturnStatement třídy.

CodeMethodReturnStatement(CodeExpression)

Inicializuje novou instanci CodeMethodReturnStatement třídy pomocí zadaného výrazu.

Vlastnosti

Name Description
EndDirectives

CodeDirectiveCollection Získá objekt, který obsahuje koncové direktivy.

(Zděděno od CodeStatement)
Expression

Získá nebo nastaví vrácenou hodnotu.

LinePragma

Získá nebo nastaví řádek, na kterém dojde k příkazu kódu.

(Zděděno od CodeStatement)
StartDirectives

CodeDirectiveCollection Získá objekt, který obsahuje direktivy start.

(Zděděno od CodeStatement)
UserData

Získá uživatelem definovatelná data pro aktuální objekt.

(Zděděno od CodeObject)

Metody

Name Description
Equals(Object)

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Získá Type aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro