値を返す return ステートメントを表します。
この型のすべてのメンバの一覧については、CodeMethodReturnStatement メンバ を参照してください。
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeStatement
System.CodeDom.CodeMethodReturnStatement
<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
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
CodeMethodReturnStatement を使用して、値を返す return ステートメントを表すことができます。 Expression プロパティは、返す値を指定します。
使用例
[Visual Basic, C#, C++] CodeMethodReturnStatement を使用して、メソッドから値を返す例を次に示します。
' 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++]
// Defines a method that returns a string passed to it.
CodeMemberMethod* method1 = new CodeMemberMethod();
method1->Name = S"ReturnString";
method1->ReturnType = new CodeTypeReference(S"System.String");
method1->Parameters->Add( new CodeParameterDeclarationExpression(S"System.String", S"text") );
method1->Statements->Add( new CodeMethodReturnStatement( new CodeArgumentReferenceExpression(S"text") ) );
// A C# code generator produces the following source code for the preceeding example code:
// private string ReturnString(string text)
// {
// return text;
// }
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.CodeDom
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System (System.dll 内)