Target Property
Collapse the table of content
Expand the table of content

WeakReference.Target Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the object (the target) referenced by the current WeakReference object.

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

'Declaration
Public Overridable Property Target As Object

Property Value

Type: System.Object
Nothing if the object referenced by the current WeakReference object has been garbage collected; otherwise, a reference to the object referenced by the current WeakReference object.

ExceptionCondition
InvalidOperationException

The reference to the target object is invalid. This exception can be thrown while setting this property if the value is a null reference or if the object has been finalized during the set operation.

After setting this property to the target object, make sure that there are no other strong references to the object; otherwise, it will not be collected. The object should also be set to null.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft