C# MemberInfo MemberType

Description

MemberInfo MemberType When overridden in a derived class, gets a MemberTypes value indicating the type of the member method, constructor, event, and so on.

Syntax

MemberInfo.MemberType has the following syntax.


public abstract MemberTypes MemberType { get; }

Example

The following example displays the member name and type of a specified class.


/*from w w  w. j  av a 2  s . co m*/

using System;
using System.Reflection;

class Mymemberinfo
{
    public static int Main()
    {
        Type MyType = Type.GetType("System.Reflection.PropertyInfo");
        MemberInfo[] Mymemberinfoarray = MyType.GetMembers();
        Console.Write(Mymemberinfoarray.GetLength(0));
        Console.Write(MyType.FullName);

        for (int counter = 0; counter < Mymemberinfoarray.Length; counter++)
        {
            Console.Write(Mymemberinfoarray[counter].Name
                + " Member type - " +
                Mymemberinfoarray[counter].MemberType.ToString());
        }
        return 0;
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo