如何解決包含運算符'& &'的錯誤不能應用於'string'和'string'類型的操作數。代碼法洛斯爲:運算符'&&'不能應用於'string'和'string'類型的操作數。
bool AttorneysData()
{
if (((txtFirstName.Text != "")
&& ((txtSurname.Text != "")
&& (txtAddress.Text
&& (txtTelNo.Text
&& (txtEmail.Text
&& (txtCreatePassword.Text
&& (txtConfirmPassword.Text
&& (cboDisciplineExpertise.Text
&& (cboGeographicalLocation.Text
&& (cboBudgetEstimation.Text
&& (txtNoofIndividuals.Text
&& (cboTypeofClients.Text
&& (txtCompanyName.Text && txtYearsofExperience.Text))))))))))))))
{
return true;
}
else
{
return false;
}
}
糾正它不能 - &&是比較布爾值 - 字符串是不是。你不打算在每個文本之後有!=「」嗎? – BugFinder
另一種讀取驗證字符串的方法是[string.IsNullOrEmpty()](https://msdn.microsoft.com/en-gb/library/system.string.isnullorempty(v = vs.110).aspx) – StuperUser
爲什麼你不再在你的條件下添加那些'!=「」'東西?前兩次,但之後?然而,所有那些奇怪的括號看起來很麻煩。省略它們。 – HimBromBeere