This documentation is archived and is not being maintained.
MemberInfo.MemberType Property
.NET Framework 1.1
Gets the type of this member, such as field, method, and so on.
[Visual Basic] Public MustOverride ReadOnly Property MemberType As MemberTypes [C#] public abstract MemberTypes MemberType {get;} [C++] public: __property virtual MemberTypes get_MemberType() = 0; [JScript] public abstract function get MemberType() : MemberTypes;
Property Value
An enumerated value from the MemberTypes class, specifying a constructor, event, field, method, property, type information, all, or custom.
Remarks
To get the MemberType property, get the class Type. From the Type, get the MethodInfo array. From the MethodInfo array, get the MemberTypes.
Example
The following example displays the member name and type of a specified class.
[Visual Basic] Imports System Imports System.Reflection Imports Microsoft.VisualBasic Class Mymemberinfo Public Shared Function Main() As Integer Console.WriteLine(ControlChars.Cr + "Reflection.MemberInfo") ' Get the Type and MemberInfo. Dim MyType As Type = Type.GetType("System.Reflection.PropertyInfo") Dim Mymemberinfoarray As MemberInfo() = MyType.GetMembers() ' Get the MemberType method and display the elements. Console.Write(ControlChars.Cr + "There are {0} members in ", _ Mymemberinfoarray.GetLength(0)) Console.Write("{0}.", MyType.FullName) Dim counter As Integer For counter = 0 To Mymemberinfoarray.Length - 1 Console.Write(ControlChars.CrLf + counter.ToString() + ". " _ + Mymemberinfoarray(counter).Name _ + " Member type - " _ + Mymemberinfoarray(counter).MemberType.ToString()) Next counter Return 0 End Function End Class [C#] using System; using System.Reflection; class Mymemberinfo { public static int Main() { Console.WriteLine ("\nReflection.MemberInfo"); // Get the Type and MemberInfo. Type MyType = Type.GetType("System.Reflection.PropertyInfo"); MemberInfo[] Mymemberinfoarray = MyType.GetMembers(); // Get the MemberType method and display the elements. Console.Write("\nThere are {0} members in ", Mymemberinfoarray.GetLength(0)); Console.Write("{0}.", MyType.FullName); for (int counter = 0; counter < Mymemberinfoarray.Length; counter++) { Console.Write("\n" + counter + ". " + Mymemberinfoarray[counter].Name + " Member type - " + Mymemberinfoarray[counter].MemberType.ToString()); } return 0; } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; int main() { Console::WriteLine (S"\nReflection.MemberInfo"); // Get the Type and MemberInfo. Type* MyType = Type::GetType(S"System.Reflection.PropertyInfo"); MemberInfo* Mymemberinfoarray[] = MyType->GetMembers(); // Get the MemberType method and display the elements. Console::Write(S"\nThere are {0} members in ", __box(Mymemberinfoarray->GetLength(0))); Console::Write(S"{0}.", MyType->FullName); for (int counter = 0; counter < Mymemberinfoarray->Length; counter++) { Console::Write(S"\n{0}. {1} Member type - {2}", __box(counter), Mymemberinfoarray[counter]->Name, __box(Mymemberinfoarray[counter]->MemberType)); } return 0; } [JScript] import System; import System.Reflection; class Mymemberinfo { public static function Main() : void { Console.WriteLine ("\nReflection.MemberInfo"); //Get the Type and MemberInfo. var MyType : Type = Type.GetType("System.Reflection.PropertyInfo"); var Mymemberinfoarray : MemberInfo[] = MyType.GetMembers(); //Get the MemberType method and display the elements. Console.Write("\nThere are {0} members in ", Mymemberinfoarray.GetLength(0)); Console.Write("{0}.", MyType.FullName); for (var counter : int in Mymemberinfoarray) { Console.Write("\n" + counter + ". " + Mymemberinfoarray[counter].Name + " Member type - " + Mymemberinfoarray[counter].MemberType.ToString()); } } } Mymemberinfo.Main();
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
MemberInfo Class | MemberInfo Members | System.Reflection Namespace | MemberTypes
Show: