Export (0) Print
Expand All

FieldInfo.IsSpecialName Property

Gets a value indicating whether the corresponding SpecialName attribute is set in the FieldAttributes enumerator.

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

public bool IsSpecialName { get; }
/** @property */
public final boolean get_IsSpecialName ()

public final function get IsSpecialName () : boolean

Not applicable.

Property Value

true if the SpecialName attribute is set in FieldAttributes; otherwise, false.

Names that begin with or contain an underscore character (_), property accessors, and operator overloading methods are examples of names that might require special treatment by some compilers.

The following example returns a value indicating whether or not the fields in the class contain a SpecialName attribute.

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

import System.*;
import System.Reflection.*;
import System.ComponentModel.Design.*;

class FieldInfoIsSpecialName
{
    public static void main(String[] args)
    {
        try {
            // Get the type handle of a specified class.
            Type myType = ViewTechnology.class.ToType();

            // 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].get_IsSpecialName()) {
                    Console.WriteLine("The field {0} has a SpecialName" 
                        + " attribute.", myField[i].get_Name());
                }
            }
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception : {0} ", e.get_Message());
        }
    } //main
} //FieldInfoIsSpecialName

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

ADD
Show:
© 2014 Microsoft