I have two text boxes and I want skip a block of code only when both are empty:
if (txtBox1.Text.Trim() != string.Empty && txtBox2.Text.Trim() != string.Empty )
{
// Do something
}
If either of the text boxes has something, I want the //Do something part to execute. Only when both are empty do I want to skip.
However the above code fragment doesn’t work. Why?
I believe you have your logical operators mixed up. What you’re looking for is