次の方法で共有


MethodInfo.ReturnType プロパティ

このメソッドの戻り値の型を取得します。

Public MustOverride ReadOnly Property ReturnType As Type
[C#]
public abstract Type ReturnType {get;}
[C++]
public: __property virtual Type* get_ReturnType() = 0;
[JScript]
public abstract function get ReturnType() : Type;

プロパティ値

このメソッドの戻り値の型。

解説

このプロパティを取得するには、初めに Type クラスを取得します。Type から MethodInfo を取得します。最後に、 MethodInfo から ReturnType を取得します。

使用例

指定したメソッドの戻り値の型を表示する例を次に示します。

 
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Class Mymethodinfo1

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.Cr + "Reflection.MethodInfo")

        'Get the Type and MethodInfo.
        Dim MyType As Type = Type.GetType("System.Reflection.FieldInfo")
        Dim Mymethodinfo As MethodInfo = MyType.GetMethod("GetValue")
        Console.Write(ControlChars.Cr _
           + MyType.FullName + "." + Mymethodinfo.Name)

        'Get and display the ReturnType.
        Console.Write(ControlChars.Cr _
           + "ReturnType = {0}", Mymethodinfo.ReturnType)
        Return 0
    End Function
End Class

[C#] 
using System;
using System.Reflection;

class Mymethodinfo
{
    public static int Main()
    {
        Console.WriteLine ("\nReflection.MethodInfo");
  
        // Get the Type and MethodInfo.
        Type MyType = Type.GetType("System.Reflection.FieldInfo");
        MethodInfo Mymethodinfo = MyType.GetMethod("GetValue");
        Console.Write ("\n" + MyType.FullName + "." + Mymethodinfo.Name);
  
        // Get and display the ReturnType.
        Console.Write ("\nReturnType = {0}", Mymethodinfo.ReturnType);
        return 0;
    }
}

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;

int main()
{
    Console::WriteLine (S"\nReflection.MethodInfo");

    // Get the Type and MethodInfo.
    Type* MyType = Type::GetType(S"System.Reflection.FieldInfo");
    MethodInfo* Mymethodinfo = MyType->GetMethod(S"GetValue");
    Console::Write (S"\n{0}.{1}", MyType->FullName, Mymethodinfo->Name);

    // Get and display the ReturnType.
    Console::Write (S"\nReturnType = {0}", Mymethodinfo->ReturnType);
    return 0;
}

[JScript] 
class Mymethodinfo
{
   public static function Main() : void
      {
      Console.WriteLine ("\nReflection.MethodInfo");
 
      //Get the Type and MethodInfo.
      var MyType : Type = Type.GetType("System.Reflection.FieldInfo");
      var Mymethodinfo : MethodInfo = MyType.GetMethod("GetValue");
      Console.Write ("\n" + MyType.FullName + "." + Mymethodinfo.Name);
 
      //Get and display the ReturnType.
      Console.Write ("\nReturnType = {0}", Mymethodinfo.ReturnType);
   }
}
Mymethodinfo.Main();
/*
This code produces the following output:

Reflection.MethodInfo
System.Reflection.FieldInfo.GetValue
ReturnType - System.Object
*/

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

MethodInfo クラス | MethodInfo メンバ | System.Reflection 名前空間