Berkeley CSUA MOTD:Entry 52806
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2018/09/20 [General] UID:1000 Activity:popular
9/20    

2009/4/6-13 [Computer/SW/Languages/C_Cplusplus] UID:52806 Activity:moderate
4/6     In C++, if there are several instances of an object, and for
        debugging purpose I want to see which instance of an object it is, I
        can do 'printf("%p", pObj);' to print out the address of the object.
        Is there any way to do something similar in C#?  Thanks.
        \_ CLR objects can get shuffled around in memory nondeterministically.
           Using the address or something like that won't work for identifying
           an object.  You need an object identifier, a UID or something
           explicitly in the object to follow it.
           \_ How do I get an object ID that I can print out?  Thanks.
           \_ How do I get an object ID that I can print out?  Thanks. -- OP
              \_ You need to set it, probably when you instantiate it.
                 \_  I see.  Thx.  -- OP