This documentation is archived and is not being maintained.

FieldAttributes Enumeration

Specifies flags that describe the attributes of a field.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

public enum FieldAttributes

Member nameDescription
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkFieldAccessMaskSpecifies the access level of a given field.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkPrivateScopeSpecifies that the field cannot be referenced.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkPrivateSpecifies that the field is accessible only by the parent type.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkFamANDAssemSpecifies that the field is accessible only by subtypes in this assembly.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkAssemblySpecifies that the field is accessible throughout the assembly.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkFamilySpecifies that the field is accessible only by type and subtypes.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkFamORAssemSpecifies that the field is accessible by subtypes anywhere, as well as throughout this assembly.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkPublicSpecifies that the field is accessible by any member for whom this scope is visible.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkStaticSpecifies that the field represents the defined type, or else it is per-instance.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkInitOnlySpecifies that the field is initialized only, and can be set only in the body of a constructor.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkLiteralSpecifies that the field's value is a compile-time (static or early bound) constant. Any attempt to set it throws FieldAccessException.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkNotSerializedSpecifies that the field does not have to be serialized when the type is remoted.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkSpecialNameSpecifies a special method, with the name describing how the method is special.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkPinvokeImplReserved for future use.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkReservedMaskReserved.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkRTSpecialNameSpecifies that the common language runtime (metadata internal APIs) should check the name encoding.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkHasFieldMarshalSpecifies that the field has marshaling information.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkHasDefaultSpecifies that the field has a default value.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkHasFieldRVASpecifies that the field has a relative virtual address (RVA). The RVA is the location of the method body in the current image, as an address relative to the start of the image file in which it is located.

FieldAttributes uses the value from FieldAccessMask to mask off only the parts of the attribute value that pertain to the accessibility. For example, the following code determines if Attributes has the public bit set:

No code example is currently available or this language may not be supported.

To get the FieldAttributes, first get the class Type. From the Type, get the FieldInfo. From the FieldInfo, get the Attributes.

The enumerated value is a number representing the bitwise OR of the attributes implemented on the field.

In this example, three fields are built and the FieldAttributes values are displayed. A FieldAttributes value can contain more than one attribute, for example, both Public and Literal, as shown in the third field.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show: