EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.
Ce sujet n'a pas encore été évalué - Évaluez ce sujet

MemberInfo.Name Property

April 12, 2014

Gets the name of the current member.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
public abstract string Name { get; }

Property Value

Type: System.String
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 Example
{
   public static int Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      outputBlock.Text += "\nReflection.MemberInfo" + "\n";

      // Get the Type and MemberInfo.
      Type MyType = Type.GetType("System.Empty");
      MemberInfo[] Examplearray = MyType.GetMembers();

      // Get and display the DeclaringType method.
      outputBlock.Text += String.Format("\nThere are {0} members in ",
          Examplearray.GetLength(0));
      outputBlock.Text += String.Format("{0}.", MyType.FullName);

      foreach (MemberInfo Example in Examplearray)
      {
         outputBlock.Text += String.Format("\n" + Example.Name
             + " declaring type - " +
             Example.DeclaringType);
      }

      return 0;
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Cela vous a-t-il été utile ?
(1500 caractères restants)
Merci pour vos suggestions.
Afficher:
© 2014 Microsoft. Tous droits réservés.