MethodInfo.ReturnType MethodInfo.ReturnType MethodInfo.ReturnType MethodInfo.ReturnType Property

定义

获取此方法的返回类型。Gets the return type of this method.

public:
 abstract property Type ^ ReturnType { Type ^ get(); };
public abstract Type ReturnType { get; }
member this.ReturnType : Type
Public MustOverride ReadOnly Property ReturnType As Type

属性值

此方法的返回类型。The return type of this method.

实现

示例

下面的示例显示指定方法的返回类型。The following example displays the return type of the specified method.

using namespace System;
using namespace System::Reflection;
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{0}.{1}", MyType->FullName, Mymethodinfo->Name );
   
   // Get and display the ReturnType.
   Console::Write( "\nReturnType = {0}", Mymethodinfo->ReturnType );
   return 0;
}

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;
    }
}
Imports System.Reflection

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

注解

若要获取返回类型属性,请首先获取类TypeTo get the return type property, first get the class Type. Type从中MethodInfo获取。From the Type, get the MethodInfo. MethodInfo从中ReturnType获取。From the MethodInfo, get the ReturnType.

适用于