Windows apps
Collapse the table of content
Expand the table of content

WeakReference<T> Class

.NET Framework (current version)
 

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)

System.Object
  System.WeakReference<T>

[SerializableAttribute]
public sealed class WeakReference<T> : ISerializable
where T : class

Type Parameters

T

The type of the object referenced.

NameDescription
System_CAPS_pubmethodWeakReference<T>(T)

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.

NameDescription
System_CAPS_pubmethodEquals(Object)

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

System_CAPS_protmethodFinalize()

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

System_CAPS_pubmethodGetHashCode()

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.

System_CAPS_pubmethodGetType()

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

System_CAPS_pubmethodSetTarget(T)

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

System_CAPS_pubmethodToString()

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

System_CAPS_pubmethodTryGetTarget(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.

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
Show:
© 2017 Microsoft