Hello everyone,
Since DateTime is struct other than class, each time when we use DateTime abc = DateTime.Now, there are two copies of DateTime structs?
1.
One instance is created by DateTime struct internally, which represents the current time, and another instance is copied from the internal instance to the value type variable abc when we perform assignment operation?
2.
I think the internal instance is a waste? Since it is useless when the value is copied to variable abc?
thanks in advance,
George

Neetika Gupta12 reputationPosted Jun 9, 2008, 8:45 PM EDT
Well I think that after the internal instance is copied to the value type variable abc, the internal instance gets disposed off implicitly.
George GeorgeRank #1,736 · 870 reputationPosted Jun 9, 2008, 8:52 PM EDT
Thanks Neetika Gupta,
So, you agree with me that two instances are created in statement DateTime abc = DateTime.Now?
regards,
George
Neetika Gupta12 reputationPosted Jun 9, 2008, 10:41 PM EDT
We can call constructor of DateTime if a particular date is to be assigned:
DateTime abc = new DateTime(2008, 6, 10) //Date is 10 Jun, 2008(midnight)
George GeorgeRank #1,736 · 870 reputationPosted Jun 9, 2008, 10:56 PM EDT
Thanks Neetika Gupta,
I agree with you. But my original question is about DateTime.Now specically, not about any time. I think you agree with my points that two instances are created? :-)
regards,
George