Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​WeakReference

Assembly: System.Runtime

Inheritance: object → WeakReference

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

Properties

public bool
IsAlive
Gets an indication whether the object referenced by the current <see cref="T:System.WeakReference" /> object has been garbage collected.
public object
Target
Gets or sets the object (the target) referenced by the current <see cref="T:System.WeakReference" /> object.
public bool
TrackResurrection
Gets an indication whether the object referenced by the current <see cref="T:System.WeakReference" /> object is tracked after it is finalized.

Methods

protected void
Finalize​()
Discards the reference to the target represented by the current <see cref="T:System.WeakReference" /> object.
public void
GetObjectData​(SerializationInfo info, StreamingContext context)
info An object that holds all the data needed to serialize or deserialize the current <see cref="T:System.WeakReference" /> object.
context (Reserved) The location where serialized data is stored and retrieved.
Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object with all the data needed to serialize the current <see cref="T:System.WeakReference" /> object.
public bool
Equals​(object obj)
Inherited from object
obj The object to compare with the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
Determines whether the specified object is equal to the current object.
public int
GetHashCode​()
Inherited from object
Returns A hash code for the current object.
Serves as the default hash function.
public Type
GetType​()
Inherited from object
Returns The exact runtime type of the current instance.
Gets the <see cref="T:System.Type" /> of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Returns A shallow copy of the current <see cref="T:System.Object" /> .
Creates a shallow copy of the current <see cref="T:System.Object" /> .
public string
ToString​()
Inherited from object
Returns A string that represents the current object.
Returns a string that represents the current object.