If( ) multiple conditions

  • Thread starter Thread starter Andrew Banks
  • Start date Start date
A

Andrew Banks

How can I tst for multiple conditions in C#?

I'm currently testing for !Page.IsPostBack and also want to test a URL
parameter. I'm not quite sure how to construct this.

if(!Page.IsPostBack AND Request.QueryString["Refreshed"].ToString()=="1")
{
do something
}
 
Andrew Banks said:
How can I tst for multiple conditions in C#? : :
if(!Page.IsPostBack AND Request.QueryString["Refreshed"].ToString()=="1")

if ( !Page.IsPostBack && Request.QueryString[ "Refreshed"].ToString( ) == "1" )

'&&' does short-circuit (conditional) AND evaluation, which means if the page is posted
back it will not check the Request's query string.

If the second term had a side-effect, you might prefer '&' which is a logical AND that
checks both terms, even when the first term returns false.


Derek Harmon
 
Back
Top