gpt4 book ai didi

c# - .NET 中是否存在弱引用?

转载 作者:太空狗 更新时间:2023-10-29 23:57:58 25 4
gpt4 key购买 nike

我想在我的应用程序中保留某类对象的列表。但我仍然希望该对象被垃圾收集。您可以在 .NET 中创建弱引用吗?

供引用:

来自 MSDN 的回答:

To establish a weak reference with an object, you create a WeakReference using the instance of the object to be tracked. You then set the Target property to that object and set the object to null. For a code example, see WeakReference in the class library.

最佳答案

是的,有一个通用的弱引用类。

MSDN > Weak Reference

关于c# - .NET 中是否存在弱引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/346885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com