.NET API Documentation

MemberInfo Class

System.Reflection

Summary

Represents a member (such as a field, method, or property) of a type, and provides access to metadata information about the member.

Remarks

MemberInfo is an abstract base class that is inherited by classes that represent specific types of members in managed code. These derived classes include:

  • FieldInfo: Represents a field of a type.
  • MethodInfo: Represents a method of a type.
  • PropertyInfo: Represents a property of a type.
  • EventInfo: Represents an event of a type.
  • ConstructorInfo: Represents a constructor of a type.

The MemberInfo class provides common properties and methods for accessing metadata, such as the member's name, declaring type, and custom attributes.

Inheritance Hierarchy

Object
  MemberInfo

Members

Properties

Name Description
Name Gets the name of the current member.
DeclaringType Gets the Type object that declares the reflected member.
ReflectedType Gets the type whose reflection information is being examined.
MemberType Gets a MemberTypes value indicating the type of the member.
MetadataToken Gets the metadata token for this member.

Methods

Name Description
GetCustomAttributes(Type attributeType, bool inherit) When overridden in a derived class, searches for the attributes of the specified type and its base types or implemented interfaces on the reflected element.
GetCustomAttributes(bool inherit) When overridden in a derived class, returns an array of custom attributes applied to this member.
IsDefined(Type attributeType, bool inherit) Determines whether the specified custom attribute is defined on this member.
Equals(Object obj) Determines whether the specified object is equal to the current object.
GetHashCode() Serves as the default hash function.
GetType() Gets the type of the current instance.
ToString() Returns a string that represents the current object.

Methods for Derived Classes

Derived classes override these methods to provide specific information about their member type.

  • FieldInfo: Methods like GetValue(Object obj), SetValue(Object obj, Object value).
  • MethodInfo: Methods like Invoke(Object obj, Object[] parameters).
  • PropertyInfo: Methods like GetValue(Object obj, Object[] index), SetValue(Object obj, Object value, Object[] index).

See Also