I’m working on a C# project where I declare two class variables:
DateTime creationDate;
byte exRecNo;
The program has a while loop in which those variables get their values assigned.
I would like to reset their values to null after every iteration through the loop so as not to retain values from the previous trip through the loop.
However, when I attempt to do this I get the following error messages:
creationDate = null;
“Cannot convert null to ‘System.DateTime’ because it is a non-nullable value type”
exRecNo = null;
“Cannot convert null to ‘byte’ because it is a non-nullable value type”
Since I can’t set them to null is there any way that I can clear their values?
To declare a primitive / non-nullable types as nullable use a
?