samedi 31 octobre 2015

C# if statement with multiple or conditions not returning expected behavior

I have an if statement that will display a .CSHTML Layout under the following conditions:

    @if ((ViewBag.title != "Log in")
    || (ViewBag.title != "Register")
    || (ViewBag.title != "Confirm Email")
    || (ViewBag.title != "Login Failure")
    || (ViewBag.title != "Forgot your password?")
    || (ViewBag.title != "Forgot Password Confirmation")
    || (ViewBag.title != "Reset password")
    || (ViewBag.title != "Reset password confirmation")
    || (ViewBag.title != "Send")
    || (ViewBag.title != "Verify"))
{ Layout markup }

When I load the Log in page; however, the Layout template appears. Setting a breakpoint shows that the page title correctly corresponds to the != "Log in" condition and no exceptions are being thrown. Just to be sure, I checked my markup against the solution in this post and it appears to be fine... Have a screwed up my statement logic somehow and just don't see it?


Aucun commentaire:

Enregistrer un commentaire