Export (0) Print
Expand All

FieldInfo.IsSpecialName Property

Gets a value that indicates whether the field has a name that has special significance.

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

public bool IsSpecialName { get; }

Property Value

Type: System.Boolean
true if the field has the FieldAttributes.SpecialName attribute set; otherwise, false.

ExceptionCondition
MethodAccessException

This member is invoked late-bound through mechanisms such as Type.InvokeMember.

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 shows whether or not the fields in the class have the FieldAttributes.SpecialName attribute.


using System;
using System.Reflection;

class Example
{
    public static void Demo(System.Windows.Controls.TextBlock outputBlock)
    {
        Type myType = typeof(EventAttributes);

        outputBlock.Text = 
            String.Format("Fields of {0}, flagging FieldAttributes.SpecialName:\n",
                          myType.Name);

        foreach (FieldInfo fi in myType.GetFields())
        {
            // Determine whether or not each field has a special name.
            if (fi.IsSpecialName)
            {
                outputBlock.Text += 
                    String.Format("{0} has the FieldAttributes.SpecialName attribute.\n", 
                                  fi.Name);
            }
            else
            {
                outputBlock.Text += fi.Name + "\n";
            }
        }
    }
}

/* This example produces output similar to the following:

Fields of EventAttributes, flagging FieldAttributes.SpecialName:
value__ has the FieldAttributes.SpecialName attribute.
None
SpecialName
ReservedMask
RTSpecialName
 */


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft