CodeMethodReturnStatement Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a return value statement.
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
- Inheritance
- Attributes
Examples
The following example demonstrates use of a CodeMethodReturnStatement to return a value from a method.
// 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.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
Remarks
CodeMethodReturnStatement can be used to represent a return value statement. The Expression property specifies the value to return.
Constructors
CodeMethodReturnStatement() |
Initializes a new instance of the CodeMethodReturnStatement class. |
CodeMethodReturnStatement(CodeExpression) |
Initializes a new instance of the CodeMethodReturnStatement class using the specified expression. |
Properties
EndDirectives |
Gets a CodeDirectiveCollection object that contains end directives. (Inherited from CodeStatement) |
Expression |
Gets or sets the return value. |
LinePragma |
Gets or sets the line on which the code statement occurs. (Inherited from CodeStatement) |
StartDirectives |
Gets a CodeDirectiveCollection object that contains start directives. (Inherited from CodeStatement) |
UserData |
Gets the user-definable data for the current object. (Inherited from CodeObject) |
Methods
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기