This topic has not yet been rated - Rate this topic

MemberInfo Class

Obtains information about the attributes of a member and provides access to member metadata.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ComVisibleAttribute(true)]
public abstract class MemberInfo : ICustomAttributeProvider

The MemberInfo type exposes the following members.

  Name Description
Protected method MemberInfo Initializes a new instance of the MemberInfo class.
Top
  Name Description
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 DeclaringType Gets the class that declares this member.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 MemberType When overridden in a derived class, gets a MemberTypes value indicating the type of the member — method, constructor, event, and so on.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 MetadataToken Gets a value that identifies a metadata element.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 Module Gets the module in which the type that declares the member represented by the current MemberInfo is defined.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 Name Gets the name of the current member.
Public property Supported by Silverlight for Windows Phone Supported by Xbox 360 ReflectedType Gets the class object that was used to obtain this instance of MemberInfo.
Top
  Name Description
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Supported by Silverlight for Windows Phone Supported by Xbox 360 Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 GetCustomAttributes(Boolean) When overridden in a derived class, returns an array of all custom attributes applied to this member.
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 GetCustomAttributes(Type, Boolean) When overridden in a derived class, returns an array of custom attributes applied to this member and identified by Type.
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 IsDefined When overridden in a derived class, indicates whether one or more attributes of the specified type or of its derived types is applied to this member.
Protected method Supported by Silverlight for Windows Phone Supported by Xbox 360 MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by Silverlight for Windows Phone Supported by Xbox 360 ToString Returns a string that represents the current object. (Inherited from Object.)
Top

The MemberInfo class is the abstract base class for classes used to obtain information about all members of a class (constructors, events, fields, methods, and properties).

This class introduces the basic functionality that all members provide.

In Silverlight-based applications, you cannot derive new types from MemberInfo.

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


using System;
using System.Reflection;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // Get the Type and MemberInfo.
      Type MyType = typeof(System.Threading.Thread);

      // Display the MemberType and the member.
      outputBlock.Text += String.Format("There are {0} members in {1}:\n", 
         MyType.GetMembers().Length, MyType.FullName);

      foreach (MemberInfo mi in MyType.GetMembers())
      {
         outputBlock.Text += String.Format("  {0} - {1}\n",
            mi.MemberType, mi);
      }
   }
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

This type is thread safe.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ