Muokkaa

Jaa


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
generic <typename T>
 where T : classpublic ref class WeakReference sealed : System::Runtime::Serialization::ISerializable
public sealed class WeakReference<T> where T : class
public sealed class WeakReference<T> : System.Runtime.Serialization.ISerializable where T : class
[System.Serializable]
public sealed class WeakReference<T> : System.Runtime.Serialization.ISerializable where T : class
type WeakReference<'T (requires 'T : null)> = class
type WeakReference<'T (requires 'T : null)> = class
    interface ISerializable
[<System.Serializable>]
type WeakReference<'T (requires 'T : null)> = class
    interface ISerializable
Public NotInheritable Class WeakReference(Of T)
Public NotInheritable Class WeakReference(Of T)
Implements ISerializable

Type Parameters

T

The type of the object referenced.

Inheritance
WeakReference<T>
Attributes
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, Boolean)

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

WeakReference<T>(T)

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

Methods

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.

GetHashCode()

Serves as the default hash function.

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

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

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
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.

Applies to