Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

how to get instance id of runtime objects in .NET?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lyubomirskiy@gmail.com - 19 Jul 2006 07:52 GMT
Hi,

I was wondering if it is possible to obtain instance id of any random
instantiated object during execution of a C# program. I am guessing
that System.Runtime namespace might be used for this, but I have no
clue as to the specifics. I cannot just insert the id field into the
class declaration, I need to be able to work with objects of already
defined classes.

As an alternative to getting instance ids I can also assign my own ids
by storing all newly created objects of all types in a hashtable, but
this would create difficulties if the object supports a nontrivial hash
function and would require chaining etc. So I am hoping to do it simply
with instance ids, if possible.

Thanks ahead of time for replying.
Lloyd Dupont - 19 Jul 2006 07:57 GMT
Why do you want that?
There is propably a more appropriate solution!

Beside there is no such thing, object memory might get moved around when
there is garbage collection.
It's transparent, every reference is in fact a double pointer.

Signature

Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>

> Hi,
>
[quoted text clipped - 12 lines]
>
> Thanks ahead of time for replying.
lyubomirskiy@gmail.com - 19 Jul 2006 08:12 GMT
I am not interested in memory location, just a unique id for each
existing object on the heap. So you are saying there are no such unique
ids, just memory addresses?

> Why do you want that?
> There is propably a more appropriate solution!
>
> Beside there is no such thing, object memory might get moved around when
> there is garbage collection.
> It's transparent, every reference is in fact a double pointer.
Lloyd Dupont - 19 Jul 2006 09:40 GMT
>I am not interested in memory location, just a unique id for each
> existing object on the heap. So you are saying there are no such unique
> ids, just memory addresses?

I am not saying that at all!

I am saying:

1. There are no such thing as a unique ID to identify object.

2. Trying to infer what you were thinking of I thought you thought of
pointer value. Hence my reply about memory which is moved around.

>> Why do you want that?
>> There is propably a more appropriate solution!
>>
>> Beside there is no such thing, object memory might get moved around when
>> there is garbage collection.
>> It's transparent, every reference is in fact a double pointer.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.