Simplify expression

Survey Solutions uses C# for writing conditions, which provides numerous alternatives in writing syntax. The following expression works, but could be simplified. How can you rewrite this enabling condition for more efficiency?

Why would you prefer the alternative (or the original) expression?

This expression is from an actual questionnaire, q is a categorical single-select question with categories 1, 2, 3, …, 44.

I prefer using this q % 2 == 1 I believe it is more efficient because don’t have to review the 22 possibles cases.

2 Likes