FieldInfo.GetRawConstantValue Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a literal value associated with the field by a compiler.
public:
virtual System::Object ^ GetRawConstantValue();
public virtual object? GetRawConstantValue ();
public virtual object GetRawConstantValue ();
abstract member GetRawConstantValue : unit -> obj
override this.GetRawConstantValue : unit -> obj
Public Overridable Function GetRawConstantValue () As Object
An Object that contains 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 null
.
The Constant table in unmanaged metadata does not contain a constant value for the current field.
The type of the value is not one of the types permitted by the Common Language Specification (CLS). See the ECMA Partition II specification Metadata Logical Format: Other Structures, Element Types used in Signatures.
The constant value for the field is not set.
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.
Note
For more information on constant values and the Constant table, see Partition II of the Common Language Infrastructure (CLI) documentation.
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.5, 1.6, 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: