WeakReference<'T> Class
Represents a typed weak reference, which references an object while still allowing that object to be reclaimed by garbage collection.
Assembly: mscorlib (in mscorlib.dll)
| Name | Description | |
|---|---|---|
![]() | WeakReference<'T>('T) | Initializes a new instance of the WeakReference<'T> class that references the specified object. |
![]() | WeakReference<'T>('T, Boolean) | Initializes a new instance of the WeakReference<'T> class that references the specified object and uses the specified resurrection tracking. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Discards the reference to the target that is represented by the current WeakReference<'T> object.(Overrides Object.Finalize().) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetObjectData(SerializationInfo, StreamingContext) | Populates a SerializationInfo object with all the data necessary to serialize the current WeakReference<'T> object. |
![]() | GetType() | |
![]() | SetTarget('T) | Sets the target object that is referenced by this WeakReference<'T> object. |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
![]() | TryGetTarget('T) | 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.
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.

