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 readonly
keyword, i.e.:
private static readonly DateTime newDateTime = new DateTime(1,1,1,1,1,1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With