MemberInfo.Name Property
.NET Framework 3.0
Gets the name of the current member.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
Only the simple name of the member is returned, not the fully qualified name.
To get the Name property, get the class Type. From the Type, get the MemberInfo array. From a MemberInfo element of the array, obtain the Name property.
This example lists the Name and DeclaringType property of each member of the specified class.
using namespace System; using namespace System::Reflection; int main() { Console::WriteLine( "\nReflection.MemberInfo" ); // Get the Type and MemberInfo. Type^ MyType = Type::GetType( "System.Empty" ); array<MemberInfo^>^Mymemberinfoarray = MyType->GetMembers(); // Get and display the DeclaringType method. Console::Write( "\nThere are {0} members in ", Mymemberinfoarray->GetLength( 0 ) ); Console::Write( "{0}.", MyType->FullName ); System::Collections::IEnumerator^ enum0 = Mymemberinfoarray->GetEnumerator(); while ( enum0->MoveNext() ) { MemberInfo^ Mymemberinfo = safe_cast<MemberInfo^>(enum0->Current); Console::Write( "\n{0} declaring type - {1}", Mymemberinfo->Name, Mymemberinfo->DeclaringType ); } }
import System.*;
import System.Reflection.*;
class MyMemberInfo
{
public static void main(String[] args)
{
Console.WriteLine("\nReflection.MemberInfo");
// Get the Type and MemberInfo.
Type myType = Type.GetType("System.Empty");
MemberInfo myMemberInfoArray[] = myType.GetMembers();
// Get and display the DeclaringType method.
Console.Write("\nThere are {0} members in ",
String.valueOf(myMemberInfoArray.GetLength(0)));
Console.Write("{0}.", myType.get_FullName());
for (int iCtr=0; iCtr < myMemberInfoArray.length; iCtr++) {
MemberInfo myMemberInfo = myMemberInfoArray[iCtr];
Console.Write(("\n" + myMemberInfo.get_Name()
+ " declaring type - " + myMemberInfo.get_DeclaringType()));
}
} //main
} //MyMemberInfo
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.Empty"); var Mymemberinfoarray : MemberInfo[] = MyType.GetMembers(); //Get and display the DeclaringType method. Console.Write("\nThere are {0} members in ", Mymemberinfoarray.GetLength(0)); Console.Write("{0}.", MyType.FullName); for (var i : int in Mymemberinfoarray) { var Mymemberinfo : MemberInfo = Mymemberinfoarray[i]; Console.Write("\n" + Mymemberinfo.Name + " declaring type - " + Mymemberinfo.DeclaringType); } } } Mymemberinfo.Main();
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: