# Length property of a list within a validation condition

When using the length of a list in a validation condition (with the relational operator “or”), if the list is not activated; the whole condition is evaluated as false regardless of the value of the other operands.

This was not the case on the previous version I think. is there any reason for this?

Example : this validation condition on q3
q0.InList(5,6) ?
(
list.Length >0 | q3 == 1
):true

PS:
Using the double operator (short-circuit) and inverting the operands or replacing list.Length>0 by either (q1 == 1 or !IsAnswered(list)) works fine.

What does “|” signify in your expression?

I think it’s “the single or” operator (it can be use in bitwise operations as well). It checks both operands even if the first is already true.
Lets replace it with the normal || , that’s not the point, we have the same result if (list.Length>0) is the first operand.

PS:
I think that we might have a NullReferenceException that the compiler should detect, but it ignores it and acts like if the expression is false. The correct condition should be like this :

q0.InList(5,6) ?
(
(list != null && list.Length >0) | q3 == 1
):true

Follow on Sergiy’s question, why not use the or operator `||`?

hello, like a said before this condition :

q0.InList(5,6) ?
(
list.Length >0 || q3 == 1
):true

produce the same result because (list.Length>0) is the first operand.

But this :

q0.InList(5,6) ?
(
q3 == 1 || list.Length >0
):true
works normally because (list.Length >0) is not evaluated if (q3 == 1) is already true.

So this what bothers me, in the first one the answer is considered invalid and in the second one it is considered valid, just by permuting operands.

1. This is normal. Please check the order of evaluation of operators in C#.

2. My question was not WHAT the operator is doing, but WHY you are using it. I think you misinterpret what it is doing.

3. Survey Solutions Designer application gives Charirfils a warning WB00238:
[WB0238]: | is used in expression. Make sure you understand the difference between | and || operators. In most cases, use ||. But nobody reads the warnings. 4. To simplify for all Survey Solutions users: never use the | operator, always use the || operator.