PropertyInfo.GetConstantValue Method
Definition
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 property by a compiler.
public:
virtual System::Object ^ GetConstantValue();
public virtual object GetConstantValue ();
public virtual object? GetConstantValue ();
abstract member GetConstantValue : unit -> obj
override this.GetConstantValue : unit -> obj
Public Overridable Function GetConstantValue () As Object
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
.
Exceptions
The Constant table in unmanaged metadata does not contain a constant value for the current property.
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.
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 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 Partition II of the Common Language Infrastructure (CLI) specification.
Applies to
Pripomienky
https://aka.ms/ContentUserFeedback.
Pripravujeme: V priebehu roka 2024 postupne zrušíme službu Problémy v službe GitHub ako mechanizmus pripomienok týkajúcich sa obsahu a nahradíme ju novým systémom pripomienok. Ďalšie informácie nájdete na stránke:Odoslať a zobraziť pripomienky pre