PropertyInfo.MemberType プロパティ

定義

このメンバーがプロパティであることを示す MemberTypes 値を取得します。

public:
 virtual property System::Reflection::MemberTypes MemberType { System::Reflection::MemberTypes get(); };
public override System.Reflection.MemberTypes MemberType { get; }
member this.MemberType : System.Reflection.MemberTypes
Public Overrides ReadOnly Property MemberType As MemberTypes

プロパティ値

このメンバーがプロパティであることを示す MemberTypes 値。

実装

次の例では、指定したメンバーの型を表示します。

using namespace System;
using namespace System::Reflection;
int main()
{
   Console::WriteLine( "\nReflection.PropertyInfo" );
   
   // Get the type and PropertyInfo.
   Type^ MyType = Type::GetType( "System.Reflection.MemberInfo" );
   PropertyInfo^ Mypropertyinfo = MyType->GetProperty( "Name" );
   
   // Read and display the MemberType property.
   Console::Write( "\nMemberType = {0}", Mypropertyinfo->MemberType );
   return 0;
}
using System;
using System.Reflection;

class Mypropertyinfo
{
    public static int Main()
    {
        Console.WriteLine("\nReflection.PropertyInfo");

        // Get the type and PropertyInfo.
        Type MyType = Type.GetType("System.Reflection.MemberInfo");
        PropertyInfo Mypropertyinfo = MyType.GetProperty("Name");

        // Read and display the MemberType property.
        Console.Write("\nMemberType = " + Mypropertyinfo.MemberType.ToString());

        return 0;
    }
}
Imports System.Reflection

Class Mypropertyinfo

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.CrLf & "Reflection.PropertyInfo")

        ' Get the type and PropertyInfo.
        Dim MyType As Type = Type.GetType("System.Reflection.MemberInfo")
        Dim Mypropertyinfo As PropertyInfo = MyType.GetProperty("Name")

        ' Read and display the MemberType property.
        Console.WriteLine("MemberType = " & _
           Mypropertyinfo.MemberType.ToString())

        Return 0
    End Function
End Class

注釈

このプロパティは をオーバーライドします MemberType。 したがって、オブジェクトの MemberInfo セット (たとえば、 によって GetMembers 返される配列) MemberType を調べると、 プロパティは、指定されたメンバーがプロパティである場合にのみを返 Property します。

MemberType は の派生クラス MemberInfo であり、このメンバーの型を指定します。 メンバー型は、コンストラクター、プロパティ、フィールド、およびメソッドです。 これは PropertyInfo プロパティであるため、返される型はプロパティです。

プロパティを MemberType 取得するには、まず クラス Typeを取得します。 から、 Typeを取得します PropertyInfo。 から 値 PropertyInfoを取得します MemberType

適用対象