MethodInfo.ReturnType 属性

获取此方法的返回类型。

**命名空间:**System.Reflection
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public Overridable ReadOnly Property ReturnType As Type
用法
Dim instance As MethodInfo
Dim value As Type

value = instance.ReturnType
public virtual Type ReturnType { get; }
public:
virtual property Type^ ReturnType {
    Type^ get ();
}
/** @property */
public Type get_ReturnType ()
public function get ReturnType () : Type

属性值

此方法的返回类型。

备注

若要获取返回类型属性 (Property),请先获取 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
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;
    }
}
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;
}
import System.*;
import System.Reflection.*;

class MyMethodInfo
{
    public static void main(String[] args)
    {
        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.get_FullName() + "." 
            + myMethodInfo.get_Name()));

        // Get and display the ReturnType.
        Console.Write("\nReturnType = {0}", myMethodInfo.get_ReturnType());
    } //main
} //MyMethodInfo
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 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

MethodInfo 类
MethodInfo 成员
System.Reflection 命名空间