Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WeakReference<T> Class

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)


public sealed class WeakReference<T> : ISerializable
where T : class

Type Parameters


The type of the object referenced.


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

System_CAPS_pubmethodWeakReference<T>(T, Boolean)

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


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Discards the reference to the target that is represented by the current WeakReference<T> object.(Overrides Object.Finalize().)


Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

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


Gets the Type of the current instance.(Inherited from Object.)


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


Returns a string that represents the current object.(Inherited from Object.)


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

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.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2018 Microsoft