Is there any way to know when an object was created?

I have no practical need, but I was wondering:

anyway, in C #, to know, for any two arbitrary objects, which one was created first?

+5
source share
3 answers

No. If the object does not have a read-only property that stores the date and time the object was created, there is no way to find out.

+8
source

Only if inside the constructor of the object you store the current date / time (note that it DateTime.Nowalmost certainly has insufficient accuracy to be useful) and provide some ways to publish this information publicly.

+8
source

storing it - log .
(, , )

, .

Most decisions stem from practical needs, this is rare - if you need something like this, you can do it custom factoryfor third-party objects or your own implementation for your own.

0
source

All Articles