Represents a return value statement.
For a list of all members of this type, see CodeMethodReturnStatement Members.
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeMethodReturnStatement
[Visual Basic] <Serializable> <ClassInterface(ClassInterfaceType.AutoDispatch)> <ComVisible(True)> Public Class CodeMethodReturnStatement Inherits CodeStatement [C#] [Serializable] [ClassInterface(ClassInterfaceType.AutoDispatch)] [ComVisible(true)] public class CodeMethodReturnStatement : CodeStatement [C++] [Serializable] [ClassInterface(ClassInterfaceType::AutoDispatch)] [ComVisible(true)] public __gc class CodeMethodReturnStatement : public CodeStatement [JScript] public Serializable ClassInterface(ClassInterfaceType.AutoDispatch) ComVisible(true) class CodeMethodReturnStatement extends CodeStatement
Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
CodeMethodReturnStatement can be used to represent a return value statement. The Expression property specifies the value to return.
[Visual Basic, C#] The following example demonstrates use of a CodeMethodReturnStatement to return a value from a method.
[Visual Basic] ' 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 [C#] // 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; // }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System.CodeDom
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
CodeMethodReturnStatement Members | System.CodeDom Namespace