FieldInfo.IsSpecialName Proprietà

Definizione

Ottiene un valore che indica se l'attributo SpecialName corrispondente è impostato sull'enumeratore FieldAttributes.

C#
public bool IsSpecialName { get; }

Valore della proprietà

true se l'attributo SpecialName è impostato in FieldAttributes; in caso contrario, false.

Implementazioni

Esempio

Nell'esempio seguente viene restituito un valore che indica se i campi della classe contengono un attributo SpecialName.

C#
using System;
using System.Reflection;
using System.ComponentModel.Design;

class FieldInfo_IsSpecialName
{
    public static void Main()
    {
        try
        {
            // Get the type handle of a specified class.
            Type myType = typeof(ViewTechnology);

            // Get the fields of the specified class.
            FieldInfo[] myField = myType.GetFields();

            Console.WriteLine("\nDisplaying fields that have SpecialName attributes:\n");
            for(int i = 0; i < myField.Length; i++)
            {
                // Determine whether or not each field is a special name.
                if(myField[i].IsSpecialName)
                {
                    Console.WriteLine("The field {0} has a SpecialName attribute.",
                        myField[i].Name);
                }
            }
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception : {0} " , e.Message);
        }
    }
}

Commenti

I nomi che iniziano con o contengono un carattere di sottolineatura (_), le funzioni di accesso alle proprietà e i metodi di overload degli operatori sono esempi di nomi che potrebbero richiedere un trattamento speciale da parte di alcuni compilatori.

Si applica a

Prodotto Versioni
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Vedi anche