Class WeakReference
Represents a weak reference, which references an object while still allowing that object to be reclaimed by garbage collection.
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
public class WeakReference
Constructors
WeakReference(Object)
Initializes a new instance of the WeakReference class, referencing the specified object.
Declaration
public extern WeakReference(object target)
Parameters
Type | Name | Description |
---|---|---|
Object | target | The object to track or null. |
Properties
IsAlive
Gets an indication whether the object referenced by the current WeakReference object has been garbage collected.
Declaration
public virtual bool IsAlive { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the object referenced by the current WeakReference object has not been garbage collected and is still accessible; otherwise, false. |
Target
Gets or sets the object (the target) referenced by the current WeakReference object.
Declaration
public virtual object Target { get; set; }
Property Value
Type | Description |
---|---|
Object | null if the object referenced by the current WeakReference object has been garbage collected; otherwise, a reference to the object referenced by the current WeakReference object. |