F
Fernando Cacciola
Hi,
I need to produce an ID number that uniquely identifies a given object
instance.
(If the object is a boxed value, well, it won't really matter, but for
_shared_ reference-types I really need a unique ID)
What's the most efficient way to do this?
I'm thinking of using a Hashtable using the objects themselves as keys and
increasing integers as IDs.
Many of the reference-types that participate have "Equivalence" semantics
for equality testing, meaning that they override .Equals() to return True
when 2 instances (same or not) have the same value; which implies that they
also override GetHashCode() so I have to use my own hash code provider; but
that's not a problem.
Any idea about an alternative approach?
A related question: is there any way to determine if an objet is shared
(more than 1 reference to it)?
TIA
Fernando Cacciola
I need to produce an ID number that uniquely identifies a given object
instance.
(If the object is a boxed value, well, it won't really matter, but for
_shared_ reference-types I really need a unique ID)
What's the most efficient way to do this?
I'm thinking of using a Hashtable using the objects themselves as keys and
increasing integers as IDs.
Many of the reference-types that participate have "Equivalence" semantics
for equality testing, meaning that they override .Equals() to return True
when 2 instances (same or not) have the same value; which implies that they
also override GetHashCode() so I have to use my own hash code provider; but
that's not a problem.
Any idea about an alternative approach?
A related question: is there any way to determine if an objet is shared
(more than 1 reference to it)?
TIA
Fernando Cacciola