PropertyInfo.MemberType Property

Definition

Gets a MemberTypes value indicating that this member is a property.

C#
public override System.Reflection.MemberTypes MemberType { get; }

Property Value

A MemberTypes value indicating that this member is a property.

Implements

Examples

The following example displays the type of the specified member.

C#
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;
    }
}

Remarks

This property overrides MemberType. Therefore, when you examine a set of MemberInfo objects - for example, the array returned by GetMembers - the MemberType property returns Property only when a given member is a property.

MemberType is a derived class of MemberInfo and specifies the type of member this is. Member types are constructors, properties, fields, and methods. Since this is a PropertyInfo property, the returned type is a property.

To get the MemberType property, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, get the MemberType value.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.5, 1.6, 2.0, 2.1