FieldAttributes Enumeration
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Specifies the attributes of a field.
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Namespace: System.ReflectionAssembly: mscorlib (in mscorlib.dll)
| Member name | Description | |
|---|---|---|
| Assembly | The field is accessible throughout the assembly. | |
| FamANDAssem | The field is accessible only by subtypes in this assembly. | |
| Family | The field is accessible only by type and subtypes. | |
| FamORAssem | The field is accessible by subtypes anywhere, as well as throughout this assembly. | |
| FieldAccessMask | Specifies the access level of a given field. | |
| HasDefault | The field has a default value. | |
| HasFieldMarshal | The field has marshaling information. | |
| HasFieldRVA | 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. | |
| InitOnly | The field is initialized only, and cannot be written after initialization. | |
| Literal | The field's value is a compile-time (static or early bound) constant. Any attempt to set it throws FieldAccessException. | |
| NotSerialized | The field does not have to be serialized when the type is remoted. | |
| PinvokeImpl | Reserved. | |
| Private | The field is accessible only by the parent type. | |
| PrivateScope | The field cannot be referenced. | |
| Public | The field is accessible by any member for whom this scope is visible. | |
| ReservedMask | Reserved. | |
| RTSpecialName | The common language runtime (internal metadata APIs) should check the name encoding. | |
| SpecialName | Specifies a special field, with the name describing how the field is special. | |
| Static | The field represents the defined type, or else it is per-instance. |
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:
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.
This example shows how to test for the enumeration members that describe access level.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |
Note: