Table of Contents

Class WeakReference

Namespace
System
Assembly
mscorlib.dll

Represents a weak reference, which references an object while still allowing that object to be reclaimed by garbage collection.

public class WeakReference
Inheritance
WeakReference
Inherited Members
Extension Methods

Constructors

WeakReference(object)

Initializes a new instance of the WeakReference class, referencing the specified object.

public WeakReference(object target)

Parameters

target object

The object to track or null.

Properties

IsAlive

Gets an indication whether the object referenced by the current WeakReference object has been garbage collected.

public virtual bool IsAlive { get; }

Property Value

bool

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.

public virtual object Target { get; set; }

Property Value

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.