flags enum bitwise operator not working as expected
<p>I'm using C# 3.5 for a mobile app on Windows Mobile 6.5 and i've been using this simple code forever but it suddenly stopped working:</p>

<pre><code>//Regroup the issues
ScanIssuesEnum NewIssues = 0;
NewIssues |= Direction1Issues;
NewIssues |= Direction2Issues;

//Remove invalid directions because we don't care about them in bidirectionnal mode
NewIssues ^= ScanIssuesEnum.InvalidDirectionIssue;
return NewIssues;
</code></pre>

<p>I checked thoroughly all my types just to make sure i wasn't using another type, everything is based off the same ScanIssuesEnum type and the type is [Flag]'ed as you can see below:</p>

<pre><code>[Flags] public enum ScanIssuesEnum
{
    TicketUsedTooSoonIssue = 1,
    TicketUsedTooLateIssue = 2,
    TicketUsageBustedIssue = 4,
    InvalidTripIssue = 8,
    InvalidDirectionIssue = 16,
    StartStopTooSoonIssue = 32,
    StartStopNotFoundIssue = 64,
    EndStopTooLateIssue = 128,
    EndStopNotFoundIssue = 256,
    MultipleUsageSameTripIssue = 512,
    MultipleUsageInFewHoursIssue = 1024,
    StudentTicketIssue = 2048,
    ConnectingTripWithinTimeframeFlag = 4096,
    UDESStudentTicketIssue = 8192,
}
</code></pre>

<p>In my current problem, i can see EndStopNotFoundIssue in both DirectionIssues, when combined into NewIssues, i get a value that contains two times EndStopNotFoundIssue. I thought it wouldn't really matter until i return the value, maybe it's just a visual IDE bug but no, the problem persists. Even worst, when i hit the line that removes the InvalidDirectionIssue flag, it adds it to the NewIssues... </p>

<p>Am i crazy? ^= is the equivalent of x = x ^ y no? So i should remove the flag, not add it right?</p>

<p>Thanks</p>

<p><strong>Edit #1 - Values of the DirectionIssues</strong></p>

<p>As requested by Wonko the sane, the values of Direction1Issue and Direction2Issue are both EndStopNotFoundIssue or 256.</p>

<p>After the line "NewIssues ^= ScanIssuesEnum.InvalidDirectionIssue;" my NewIssues is composed of "EndStopNotFoundIssue  | EndStopNotFoundIssue  | InvalidDirectionIssue". And obviously it shouldn't!</p>

<p><strong>Edit #2 - Values of DirectionIssues wrongly read</strong></p>

<p>Ha, the two DirectionIssues had different values, i was just reading them incorrectly. In fact it was EndStopNotFoundIssue and EndStopTooLateIssue. Damn mind not read the whole words hehe. So the OR portion was fine, it was my brain playing tricks on me.</p>

<p>I changed the problematic portion about the InvalidDirectionIssue that i'm trying to XOR out using the "x = x &amp; ~y" form and it works, dunno why it works while the "x ^= y" doesn't but hell! Solution found!</p>
