CodeMethodReturnStatement-Klasse
Stellt eine Rückgabewertanweisung dar.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeMethodReturnStatement
Inherits CodeStatement
'Usage
Dim instance As CodeMethodReturnStatement
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeMethodReturnStatement : CodeStatement
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class CodeMethodReturnStatement : public CodeStatement
/** @attribute SerializableAttribute() */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public class CodeMethodReturnStatement extends CodeStatement
SerializableAttribute
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
ComVisibleAttribute(true)
public class CodeMethodReturnStatement extends CodeStatement
Hinweise
Mit CodeMethodReturnStatement kann eine Rückgabewertanweisung dargestellt werden. Die Expression-Eigenschaft gibt den zurückzugebenden Wert an.
Beispiel
Im folgenden Beispiel wird veranschaulicht, wie mit einem CodeMethodReturnStatement ein Wert aus einer Methode zurückgegeben wird.
' 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
Vererbungshierarchie
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeMethodReturnStatement
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0