- Derived from
The annotated property or method (when passed the same arguments) will return the same object reference or value throughout the lifetime of the object.
A default value (for example
null) may be returned when the object has not been initialized yet or if the object has already been disposed. Otherwise, the same value will be returned. In consequence, constant properties are thread-safe once initialization has finished, until disposal has begun.
Simple objects usually do not have a dedicated mechanism for initialization and disposal, then initialization is performed by the constructor and disposal is performed implicitly when the object is deleted because it is no longer referenced. In these cases, constant properties are always thread-safe.
Even if a constant member returns the same object, the object’s state may still vary over time. For example, a list or set may contain different elements at different points in time.