I am using a bitwise enum to return a value from a function
[Flags]
private enum PatientRecord { NoRecord=0x0, SameEnrollmentDate=0x1, SameScreeningDate=0x2 }
and have a function with
var returnVar = PatientRecord.NoRecord;
....
if (condition...)
{
returnVar &= PatientRecord.SameEnrollmentDate;
}
return returnVar
The debugger is showing that returnVar has the same value before and after the AND assignment operator has executed (be that PatientRecord.NoRecord (0) or PatientRecord.SameScreeningDate (2)).
why is this, and are there any solutions neater than:
returnVar = returnVar & PatientRecord.SameEnrollmentDate;
Thanks.