.NET Framework Class Library  

MethodInfo.ReturnType Property

Gets the return type of this method.

[Visual Basic]
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;

Property Value

The return type of this method.

Remarks

To get the return type property, first get the class Type. From the Type, get the MethodInfo. From the MethodInfo, get the ReturnType.

Example

[Visual Basic, C#, JScript] The following example displays the return type of the specified method.

[Visual Basic] 
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;
    }
}

[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
*/

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

See Also

MethodInfo Class | MethodInfo Members | System.Reflection Namespace