Overview

Represents a member (such as a field, method, or property) of a type. This is an abstract base class that provides a common mechanism for accessing properties of members and serves as the base class for types that represent individual members.

The MemberInfo class and its derived classes allow you to use reflection to discover information about your code's metadata, such as the name, type, and modifiers of members, as well as to access member values.

Syntax


public abstract class MemberInfo : ICustomAttributeProvider
                    

Namespace:System.Reflection

Assembly:System.Private.CoreLib (in System.Private.CoreLib.dll)

Inheritance

Inheritance Hierarchy

    • object
    • MemberInfo
      • FieldInfo
      • MethodBase (abstract)
      • PropertyInfo
      • EventInfo
      • TypeInfo (abstract)
      • ConstructorInfo
      • ...

Fields

MemberInfo does not declare any fields.

Properties

Properties
DeclaringType
Type DeclaringType { get; }

Gets the class that declares the member.

MetadataToken
int MetadataToken { get; }

Gets the metadata token for this member.

Name
string Name { get; }

Gets the name of the member.

ReflectedType
Type ReflectedType { get; }

Gets the type that was queried to get this member.

MemberType
MemberTypes MemberType { get; }

Gets the type of the member.

Methods

Methods
Equals
bool Equals(object obj)

Determines whether the specified object equals the current object.

GetCustomAttributes
object[] GetCustomAttributes(bool inherit)

When overridden in a derived class, returns an array of custom attribute objects that are directly applied to this member, and identifies whether the applied custom attributes are inherited or not.

GetCustomAttributes
object[] GetCustomAttributes(Type attributeType, bool inherit)

When overridden in a derived class, searches for the specified attribute type on this member, and returns either all the custom attribute objects, or all the custom attribute objects that match the specified type. Identifies whether the applied custom attributes are inherited or not.

GetHashCode
int GetHashCode()

Serves as the default hash function.

IsDefined
bool IsDefined(Type attributeType, bool inherit)

Indicates whether or not attribute data is associated with this member.

Attributes

The MemberInfo class is abstract and does not have attributes directly applied to it. Its derived classes may have specific attributes.