ASP.Net mysterious behaviour
- by kalan
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.