✅ Disjunctive patterns negation
Hey there.
I was wondering why my disjunctive is not working as intended:
The last expression result doesn't make sense for me, because I'm checking if
authUser.Level
is not Administrator
or Internal
, and it actually is Internal
as shown in the first expression, so the result should be false
.
What i'm doing wrong?10 Replies
probably need to use parenthesis around your
or
for the not
to function as expectedhttps://dotnetfiddle.net/CG4qNG
working example
C# Online Compiler | .NET Fiddle
Test your C# code online with .NET Fiddle code editor.
but why putting an parenthesis on it? does
(UserLevel.Administrator or UserLevel.Internal)
produces an enum with equality to both values or am i missing something else?Because your example shows that it is clearly matching against
not UserLevel.Administrator
and UserLevel.Internal
so the ideal, without the parenthesis, would be
authUser.Level is not UserLevel.Internal and not UserLevel.Administrator
?correct
pretty confusing
but that's it, thank you
:PepoSalute:
$close
Use the /close command to mark a forum thread as answered