Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

.Net Performance tip - 3

3.60/5 (8 votes)
22 May 2010CPOL 16.9K  
.Net Performance tip - 3
.Net Performance tip - 3

Last week i was trying to explore how the if statement performs under various conditions as shown below.

if( statement 1)
{
 if( statement 2)
 {
  if( statement 3)
  {
   ......
  }
 }
}


vs

if( statement 1 && statement 2 && statement 3)
{
  .....
}



The results indicate that, the second approach is far better than the first one.

Hence, the recommendation would be to use the second approach over the first one

I hope this helps!.

Regards,
-Vinayak

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)