We run our own serialization tool in our project and are faced with the need to uniquely identify each object using a primitive value type that can be used as a synonym for its โidentityโ. The value should not have any meaning or organization, but simply because it is unique and constant, at least throughout the serialization process. Ideally .net would internally support a unique and persistent object identifier that we could store as an object identifier. I know that every object has a GetHashCode method, but we are not sure about the value of global uniqueness. Another criterion for accessing this identifier is that the method must be very efficient.
I looked at GetHashCode , a garbage collector and sorting ideas, haven't come up with anything yet.
source share