MemberInfo.Name-Eigenschaft
Ruft den Namen des aktuellen Members ab.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public MustOverride ReadOnly Property Name As String
'Usage
Dim instance As MemberInfo
Dim value As String
value = instance.Name
public abstract string Name { get; }
public:
virtual property String^ Name {
String^ get () abstract;
}
/** @property */
public abstract String get_Name ()
public abstract function get Name () : String
Eigenschaftenwert
Eine String-Klasse mit dem Namen des Members.
Hinweise
Es wird nur der einfache Name des Members und nicht der vollqualifizierte Name zurückgegeben.
Um die Name-Eigenschaft abzurufen, rufen Sie die Type-Klasse ab. Rufen Sie aus Type das MemberInfo-Array ab. Aus einem MemberInfo-Element des Arrays rufen Sie dann die Name-Eigenschaft ab.
Beispiel
In diesem Beispiel wird die Name-Eigenschaft und die DeclaringType-Eigenschaft für jeden Member der angegebenen Klasse aufgelistet.
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Class Mymemberinfo
Public Shared Function Main() As Integer
Console.WriteLine("Reflection.MemberInfo")
' Get the Type and MemberInfo.
Dim MyType As Type = Type.GetType("System.Empty")
Dim Mymemberinfoarray As MemberInfo() = MyType.GetMembers()
' Get and display the DeclaringType method.
Console.WriteLine("There are {0} members in {1}", Mymemberinfoarray.GetLength(0), MyType.FullName)
Dim Mymemberinfo As MemberInfo
For Each Mymemberinfo In Mymemberinfoarray
Console.WriteLine(Mymemberinfo.Name & " declaring type - " & Mymemberinfo.DeclaringType.ToString())
Next Mymemberinfo
Return 0
End Function
End Class
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.Empty");
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);
foreach (MemberInfo Mymemberinfo in Mymemberinfoarray)
{
Console.Write("\n" + Mymemberinfo.Name
+ " declaring type - " +
Mymemberinfo.DeclaringType);
}
return 0;
}
}
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();
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
MemberInfo-Klasse
MemberInfo-Member
System.Reflection-Namespace