WeakReference<T> WeakReference<T> WeakReference<T> WeakReference<T> Class

Definition

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

generic <typename T>
 where T : classpublic ref class WeakReference sealed : System::Runtime::Serialization::ISerializable
public sealed class WeakReference<T> : System.Runtime.Serialization.ISerializable where T : class
type WeakReference<'T (requires 'T : null)> = class
    interface ISerializable
Public NotInheritable Class WeakReference(Of T)
Implements ISerializable
Type Parameters
T

The type of the object referenced.

Inheritance
WeakReference<T>WeakReference<T>WeakReference<T>WeakReference<T>
Implements

Remarks

A weak reference enables the garbage collector to collect an object while still allowing an application to access the object. If you need the object, you can obtain a strong reference to it and prevent it from being collected.

Constructors

WeakReference<T>(T) WeakReference<T>(T) WeakReference<T>(T) WeakReference<T>(T)

Initializes a new instance of the WeakReference<T> class that references the specified object.

WeakReference<T>(T, Boolean) WeakReference<T>(T, Boolean) WeakReference<T>(T, Boolean) WeakReference<T>(T, Boolean)

Initializes a new instance of the WeakReference<T> class that references the specified object and uses the specified resurrection tracking.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

Discards the reference to the target that is represented by the current WeakReference<T> object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo object with all the data necessary to serialize the current WeakReference<T> object.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetTarget(T) SetTarget(T) SetTarget(T) SetTarget(T)

Sets the target object that is referenced by this WeakReference<T> object.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
TryGetTarget(T) TryGetTarget(T) TryGetTarget(T) TryGetTarget(T)

Tries to retrieve the target object that is referenced by the current WeakReference<T> object.

Applies to