GetRawConstantValue Method
Collapse the table of content
Expand the table of content

FieldInfo.GetRawConstantValue Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns a literal value associated with the field by a compiler.

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

'Declaration
Public Overridable Function GetRawConstantValue As Object

Return Value

Type: System.Object
The literal value associated with the field. If the literal value is a class type with an element value of zero, the return value is Nothing.

ExceptionCondition
InvalidOperationException

The Constant table in unmanaged metadata does not contain a constant value for the current property.

FormatException

The type of the value is not one of the types permitted by the Common Language Specification (CLS). (See the ECMA Partition II specification.)

MethodAccessException

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

This method is provided for designers of managed compilers and code analyzers.

This method can be used in both the execution context and the reflection-only context.

In unmanaged metadata, the Constant table is used to store constant values for fields, parameters, and properties. Constant information does not directly influence runtime behavior. Compilers inspect this information, at compile time, when importing metadata. If used, the value of a constant is embedded in the Microsoft intermediate language (MSIL) stream the compiler emits. There are no MSIL instructions that can be used to access the Constant table at run time.

NoteNote:

For more information on constant values and the Constant table, see the ECMA Partition II documentation. The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft