C# - Get number of references to object

前端 未结 5 2024
醉梦人生
醉梦人生 2020-12-05 05:37

I\'m trying to write a simple Resource Manager for the little hobby game I\'m writing. One of the tasks that this resource manager needs to do is unloading unused resources.

5条回答
  •  长情又很酷
    2020-12-05 06:13

    We already have a resource manager in .NET, called the Garbage collector. So a very efficient approach is to set the references to null and do nothing.

    A more direct answer: No, there is no way to get the references to an object.

    You may want to study the WeakReference class or use a Caching system.

提交回复
热议问题