Thursday, 22 August 2013

Copy value of a DateTime

Copy value of a DateTime

I'm sure this is painfully trivial, but I'm trying to do something like this:
DateTime dt1;
DateTime dt2;
At some point, dt1 is given the value DateTime.Now. Later, I want to put
the value of dt1 into dt2 and then put DateTime.Now in dt1 again. When I
try to assign dt2 = dt1 and then do dt1 = DateTime.Now, dt2 now contains
the DateTime.Now I put in dt1, so it is clearly using references instead
of assigning values.
How can I accomplish what I want?

No comments:

Post a Comment