I have a number of objects in my project which have fields that will contain matching values when they’re initialized – see the code snippet below for an example, in
particular the AddedDateTime and ModifiedDateTime properties:
User user = new User()
{
FirstName = "Tex",
Surname = "Murphy",
AddedDateTime = DateTime.Now,
ModifiedDateTime = DateTime.Now
};
Is it possible to set the value of ModifiedDateTime to the value of AddedDateTime, within the {…} block once it has been set?
I have a feeling it’s not possible but thought it worth asking for confirmation.
I’m not sure if this what your after or not, but is this appropriate?
If you want to have them to initialize to the same value then you must set to a common variable value.