参考柜台 [英] Reference counters

查看:77
本文介绍了参考柜台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法确定对象的引用数量?我只需要
需要一个参考计数。


谢谢你,

比尔

Is there a way to determine the number of references to an object? I only
need a reference count.

Thank you,
Bill

推荐答案

Bill O写道:
有没有办法确定对象的引用数量?我只需要一个引用计数。
Is there a way to determine the number of references to an object? I only
need a reference count.




一个简单的方法是在类中添加一个静态计数器变量和

在构造函数中递增计数器。每次连续创建

和类的实例都会增加计数器。



A simple way would be to add a static counter variable to the class and
in the constructor increment the counter. Each successive creation of
and instance of the class will increment the counter.




" ;比尔奥 < billo @ _imt_net>在消息中写道

新闻:uT ************** @ TK2MSFTNGP09.phx.gbl ...

"Bill O" <billo@_imt_net> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
有没有办法确定对象的引用数量?我只需要一个引用计数。

谢谢,
比尔
Is there a way to determine the number of references to an object? I only
need a reference count.

Thank you,
Bill




管理对象没有参考。由CLR计算,所以你不能得到数字

的参考资料。

如果你真的需要这个,你必须自己维护一个柜台。

好​​奇,你为什么需要这个?


Willy。



Managed object aren''t ref. counted by the CLR, so you can''t get the number
of references.
If you really need this you will have to maintain a counter yourself.
Just curious, why would you need this?

Willy.




Bill O < billo @ _imt_net>在消息中写道

新闻:uT ************** @ TK2MSFTNGP09.phx.gbl ...

"Bill O" <billo@_imt_net> wrote in message
news:uT**************@TK2MSFTNGP09.phx.gbl...
有没有办法确定对象的引用数量?我只需要一个参考计数。
Is there a way to determine the number of references to an object? I only
need a reference count.




一个普通的旧日常物品?我不这么认为。



A normal old every-day object? I don''t think so.


这篇关于参考柜台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆