How can I find out how many objects are created of a class

后端 未结 2 1339
醉酒成梦
醉酒成梦 2020-12-03 15:28

How can I find out how many objects are created of a class in C#?

2条回答
  •  青春惊慌失措
    2020-12-03 16:18

    Is this a class that you've designed?

    If so, add a counter to the class that is incremented in the constructor and decremented in Dispose.

    Potentially you could make this a performance counter so you can track it in Performance Monitor.

提交回复
热议问题