It is much easier to solve this problem mathematically by simply replacing your long variable names with letters type A
or B
, replacing the symbol &&
with a simple and
or AND
or e
, (and ignoring, for practical reasons, that "3" and "4" are strings ). In your case we have:
cmbCdTipoProcesso.SelectedValue != "3" && cmbCdTipoProcesso.SelectedValue != "4"
That translated more simply means:
A != 3 e A != 4
That is:
A é diferente de 3 e A é diferente de 4
Assume A
is 3.
Let's check the expression:
A é diferente de 3 e A é diferente de 4
The expression above will be evaluated false , because A = 3
, even A != 4
.
If A
was 4, we would be in the same situation.
>
In a more general case, where times A
and if
to be valued:
if A != 3 e B != 4
That is, according to one of the laws of De Morgan :
if !(A == 3 ou B == 4)
that is, in Portuguese:
se não (A igual a 3 ou B igual a 4)
In other words, the A
block will be executed when the situation in parentheses is false ( because the false denial is true ), ie all cases where A is different from 3 and B is different from 4 at the same time , for example:
A = 2 // A é diferente de 3
B = 7 // B é diferente de 4
If A is equal to 3 or B is equal to 4 , or both, the expression of
B
will not be considered true. I repeat,
if
has to be different from 3 and
if
has to be different from 4, otherwise the
A
block will not be executed.