[Solved] operator ‘&&’ cannot be applied to operands of type ‘string’ and ‘string’


You need to use logical operators each time. IF you want to chack all strings to inequality to empty string then use String.IsNullOrEmpty() method instead of != operator.

Also there is no reason to use () in your expression. You need to use brackets to prioritize operations but in your code there is no prioritets conflict because all operations can executes successively from left to right.

Your if statement already contains logical expression that returns boolean result then you can swap it with return operator.

return String.IsNullOrEmpty(txtFirstName.Text)
            && String.IsNullOrEmpty(txtSurname.Text)
            && String.IsNullOrEmpty(txtAddress.Text)
            && String.IsNullOrEmpty(txtTelNo.Text)
            && String.IsNullOrEmpty(txtEmail.Text)
            && String.IsNullOrEmpty(txtCreatePassword.Text)
            && String.IsNullOrEmpty(txtConfirmPassword.Text)
            && String.IsNullOrEmpty(cboDisciplineExpertise.Text)
            && String.IsNullOrEmpty(cboGeographicalLocation.Text)
            && String.IsNullOrEmpty(cboBudgetEstimation.Text)
            && String.IsNullOrEmpty(txtNoofIndividuals.Text)
            && String.IsNullOrEmpty(cboTypeofClients.Text)
            && String.IsNullOrEmpty(txtCompanyName.Text) 
            && String.IsNullOrEmpty(txtYearsofExperience.Text);

solved operator ‘&&’ cannot be applied to operands of type ‘string’ and ‘string’