I have attempted the following code which will not work
private const DateTime newDateTime = new DateTime(1,1,1,1,1,1);
to which the compiler states “DateTime variable cannot be declared as const”.
I am wondering how to make this object immutable, as i do not want to be able to change it anywhere by mistake. This value will be used as a check value to compare other DateTime objects to.
Thanks for any help.
Make it static and mark with
readonlykeyword, i.e.: