ASP.Net mysterious behaviour
        Posted  
        
            by kalan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by kalan
        
        
        
        Published on 2010-05-24T12:27:03Z
        Indexed on 
            2010/05/24
            12:31 UTC
        
        
        Read the original article
        Hit count: 271
        
Does anyone have any idea why this works (expression in the if-clause)
if (!(childNode.Roles != null && !Helper.HasEqualElements((string[])childNode.Roles, System.Web.Security.Roles.GetRolesForUser())))
            AddNode(childNode, parentNode);
And this doesn't
if (childNode.Roles == null || Helper.HasEqualElements((string[])childNode.Roles, System.Web.Security.Roles.GetRolesForUser()))
            AddNode(childNode, parentNode);
The problem is that the second if-clause sometimes doesn't work. Though it always works in debug mode, but it sometimes fails while running. And the strange thing is that these two pieces of code seems absolutely equal for me.
© Stack Overflow or respective owner