MethodInfo.ReturnType Property

Gets the return type of this method.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

public virtual Type ReturnType { get; }

Property Value

Type: System.Type
The return type of this method.

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

The following example displays the return type of the specified method.


using System;
using System.Reflection;

class Example
{
   public static int Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      outputBlock.Text += "\nReflection.MethodInfo" + "\n";

      // Get the Type and MethodInfo.
      Type MyType = Type.GetType("System.Reflection.FieldInfo");
      MethodInfo Example = MyType.GetMethod("GetValue");
      outputBlock.Text += "\n" + MyType.FullName + "." + Example.Name;

      // Get and display the ReturnType.
      outputBlock.Text += String.Format("\nReturnType = {0}", Example.ReturnType);
      return 0;
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2015 Microsoft