Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i am checking one lengthy if condition but am getting this error-Operator '&&' cannot be applied to operands of type 'int' and 'bool'.What is the problem?

What I have tried:

 if ((IndexSearchCOB == 0 && IndexSearchOH == 0 && IndexSearchPCSA > 0) || (IndexSearchCOB > 0 && IndexSearchOH == 0 && IndexSearchPCSA > 0) || (IndexSearchCOB = 0 && IndexSearchOH > 0 && IndexSearchPCSA > 0) || (IndexSearchCOB > 0 && IndexSearchOH > 0 && IndexSearchPCSA > 0))

 

{

// mylogic

}
Posted
Updated 18-Aug-22 3:34am
v2
Comments
PIEBALDconsult 18-Aug-22 9:34am    
Use more parentheses and space to help human readers understand.

1 solution

Quote:
C#
IndexSearchCOB = 0 && IndexSearchOH > 0
You need a second = here:
C#
IndexSearchCOB == 0 && IndexSearchOH > 0

NB: Your statement can be dramatically simplified without changing the meaning:
C#
if (IndexSearchCOB >= 0 && IndexSearchOH >= 0 && IndexSearchPCSA > 0)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900