弱引用Weak References

短弱引用和长弱引用Short and Long Weak References

• ShortShort

垃圾回收功能回收对象后，短弱引用的目标会变为 nullThe target of a short weak reference becomes null when the object is reclaimed by garbage collection. 弱引用本身是托管对象，与其他任何托管对象一样需要经过垃圾回收。The weak reference is itself a managed object, and is subject to garbage collection just like any other managed object. 短弱引用是 WeakReference 的默认构造函数。A short weak reference is the default constructor for WeakReference.

• LongLong

在对象的 Finalize 方法已调用后，长弱引用获得保留。A long weak reference is retained after the object's Finalize method has been called. 这样，便可以重新创建该对象，但该对象仍保持不可预知的状态。This allows the object to be recreated, but the state of the object remains unpredictable. 若要使用长引用，请在 WeakReference 构造函数中指定 trueTo use a long reference, specify true in the WeakReference constructor.

如果对象类型不包含 Finalize 方法，应用的是短弱引用功能。弱引用只在目标被收集前有效，运行终结器后可以随时收集目标。If the object's type does not have a Finalize method, the short weak reference functionality applies and the weak reference is valid only until the target is collected, which can occur anytime after the finalizer is run.