Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

MethodInfo.MemberType (Propiedad)

 

Obtiene un valor de MemberTypes que indica que este miembro es un método.

Espacio de nombres:   System.Reflection
Ensamblado:  mscorlib (en mscorlib.dll)

public override MemberTypes MemberType { get; }

Valor de propiedad

Type: System.Reflection.MemberTypes

Valor de MemberTypes que indica que este miembro es un método.

This property overrides P:System.Reflection.MemberInfo.MemberType. Therefore, when you examine a set of T:System.Reflection.MemberInfo objects — for example, the array returned by Overload:System.Type.GetMembers — the P:System.Reflection.MemberInfo.MemberType property returns F:System.Reflection.MemberTypes.Method only when a given member is a method.

To get the MemberType property, first get the class Type. From the Type, get the MethodInfo. From the MethodInfo, get the MemberType.

The following example displays the type of the specified member.

using System;
using System.Reflection;

class MyMethodInfo
{
    public static int Main()
    {
        Console.WriteLine("Reflection.MethodInfo");

        // Get the Type and MethodInfo.
        Type MyType = Type.GetType("System.Reflection.FieldInfo");
        MethodInfo Mymethodinfo = MyType.GetMethod("GetValue");
        Console.WriteLine(MyType.FullName + "." + Mymethodinfo.Name);

        // Get and display the MemberType property.
        MemberTypes Mymembertypes = Mymethodinfo.MemberType;


        if (MemberTypes.Constructor == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type All.");
        }
        else if (MemberTypes.Custom == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Custom.");
        }
        else if (MemberTypes.Event == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Event.");
        }
        else if (MemberTypes.Field == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Field.");
        }
        else if (MemberTypes.Method == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Method.");
        }
        else if (MemberTypes.Property == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type Property.");
        }
        else if (MemberTypes.TypeInfo == Mymembertypes)
        {
            Console.WriteLine("MemberType is of type TypeInfo.");
        }

        return 0;
    }
}

.NET Framework
Disponible desde 1.1
Silverlight
Disponible desde 2.0
Windows Phone Silverlight
Disponible desde 7.0
Volver al principio
Mostrar: