if or statment

  • Thread starter Thread starter David Hubball
  • Start date Start date
D

David Hubball

Hi

I know this topic will be really easy for most people in this group
but can someone help me to get this statement working please. Thanks

if (txtFirstPrize.Text==""|txtSecondPrize.Text=""|
txtThirdPrize.Text="") return;

I'm just tryng to get my program to return is any of these 3
properties are blanks.

Thanks
David
 
Hi

Sorry to waste anyones time.

I've worked out the answer - my command should of been :-
if (txtFirstPrize.Text == "" | txtSecondPrize.Text =="" |
txtThirdPrize.Text =="") return;

So everyone can ignore this topic

thanks
David.
 
You really should be using ||, and possibly also string.IsNullOrEmpty
 
Why exactly does FxCop recommend using string.IsNullOrEmpty? Is it more
efficient?
 
jp2msft said:
Why exactly does FxCop recommend using string.IsNullOrEmpty? Is it more
efficient?
Yes, basically. See http://msdn.microsoft.com/library/ms182279

It's also slightly more obvious: it may not be intuitive that a test of the
form 's == ""' tests that the string is empty and not-null (and a test of
the form 's != ""' tests if it's non-empty *or* null).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top