MethodInfo.ReturnType 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得這個方法的傳回型別 (Return Type)。
public:
virtual property Type ^ ReturnType { Type ^ get(); };
public:
abstract property Type ^ ReturnType { Type ^ get(); };
public virtual Type ReturnType { get; }
public abstract Type ReturnType { get; }
member this.ReturnType : Type
Public Overridable ReadOnly Property ReturnType As Type
Public MustOverride ReadOnly Property ReturnType As Type
屬性值
這個方法的傳回型別。
實作
範例
下列範例會顯示指定方法的傳回型別。
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
備註
若要取得傳回型別屬性,請先取得 類別 Type
。
Type
從取得 MethodInfo
。
MethodInfo
從取得 ReturnType
。