-
DateTime.Now
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
-
There's nothing internal, it's just a chunk of data (8 bytes unless mistaken).
Not really much different than typing:
Code:
int abc = int.MaxValue;
(MaxValue being a constant rather than a property, but principle's the same)
Unlike C++, a struct has not much in common with a class