Anyone please hel开发者_如何学JAVAp me, my problem is this i want to check in c#, more textbox values conditions using 'if' statement like this,
if(txtbox1.Text == "" && txtbox2.Text == "" && ...&&txtboxN.Text =="")
{
MessageBox.Show("Please enter the details");
return;
}
but when i use more condition it is not taking the 'second' and others conditions.. what is the solution for this?
It sounds like you want or NOT and (i.e. swap the &&
for ||
).
I think you want to use OR not AND:
if(txtbox1.Text == "" || txtbox2.Text == "" || ...||txtboxN.Text =="")
This will show the message box if at least one text box is empty.
You have to use &, not &&.
With && if first condition is false, other conditions are not evaluated at all.
Anyway for your example I think you should use ||
, so if one of textboxes is empty your message is shown.
精彩评论