MemberInfo Class
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Obtains information about the attributes of a member and provides access to member metadata.
Inheritance Hierarchy
System.Object
System.Reflection.MemberInfo
System.Reflection.EventInfo
System.Reflection.FieldInfo
System.Reflection.MethodBase
System.Reflection.PropertyInfo
System.Type
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<ClassInterfaceAttribute(ClassInterfaceType.None)> _
<ComVisibleAttribute(True)> _
Public MustInherit Class MemberInfo _
Implements ICustomAttributeProvider
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ComVisibleAttribute(true)]
public abstract class MemberInfo : ICustomAttributeProvider
The MemberInfo type exposes the following members.
Properties
Name | Description | |
---|---|---|
DeclaringType | Gets the class that declares this member. | |
MemberType | When overridden in a derived class, gets a MemberTypes value indicating the type of the member — method, constructor, event, and so on. | |
MetadataToken | Gets a value that identifies a metadata element. | |
Module | Gets the module in which the type that declares the member represented by the current MemberInfo is defined. | |
Name | Gets the name of the current member. | |
ReflectedType | Gets the class object that was used to obtain this instance of MemberInfo. |
Top
Methods
Name | Description | |
---|---|---|
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
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.) | |
GetCustomAttributes(Boolean) | When overridden in a derived class, returns an array of all custom attributes applied to this member. | |
GetCustomAttributes(Type, Boolean) | When overridden in a derived class, returns an array of custom attributes applied to this member and identified by Type. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
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. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
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.
Examples
The following example displays the member name and type of a specified class.
Note: |
---|
To run this example, see Building Examples That Use a Demo Method and a TextBlock Control. |
Imports System.Reflection
Class Example
Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
' Get the Type and MemberInfo.
Dim MyType As Type = GetType(System.Threading.Thread)
' Display the MemberType and the member.
outputBlock.Text &= String.Format("There are {0} members in {1}:" & vbLf, _
MyType.GetMembers().Length, MyType.FullName)
For Each mi As MemberInfo In MyType.GetMembers()
outputBlock.Text &= String.Format(" {0} - {1}" & vbLf, _
mi.MemberType, mi)
Next
End Sub
End 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);
}
}
}
Version Information
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
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Thread Safety
This type is thread safe.