📜  c# week refrences - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:00.505000             🧑  作者: Mango

代码示例1
WeakReference foo = new WeakReference(new Foo());

((Foo)brokerRef.Target).Bar();
((Foo)brokerRef.Target).Baz();
GC.Collect();
GC.WaitForPendingFinalizers();

Assert.IsFalse(foo.IsAlive);