Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MemberInfo.Name Property

Gets the name of the current member.

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)

public abstract string Name { get; }
/** @property */
public abstract String get_Name ()

public abstract function get Name () : String

Not applicable.

Property Value

A String containing the name of this member.

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 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;
    }
}

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.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

Show:
© 2014 Microsoft