System.Reflection.PropertyInfo.GetConstantValue Method

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

Syntax

public virtual object GetConstantValue ()

Returns

An object that contains the literal value associated with the property. If the literal value is a class type with an element value of zero, the return value is null.

Remarks

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

Note:

Do not use this method in the reflection-only context, because it might cause code to execute. Use the PropertyInfo.GetRawConstantValue method instead.

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 the ECMA Partition II documentation. The documentation is available online; see tp://go.microsoft.com/fwlink/?LinkID=99212 on MSDN and tp://go.microsoft.com/fwlink/?LinkID=65552 on the Ecma International Web site.

Requirements

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0