Two if conditions or one if with OR

Posted by Ram on Stack Overflow See other posts from Stack Overflow or by Ram
Published on 2010-05-31T05:57:07Z Indexed on 2010/05/31 6:02 UTC
Read the original article Hit count: 112

Filed under:
|
|

I have a small doubt

I have following code

bool res= false;
if(cond1)
{
   res = true;
}

if(cond2)
{
   res = true;
}

Instead of this if I put following code

if(cond1 || cond2)
{
   res = true;
}

Which code snippet will be more optimized?

I believe it would be second one as I have avoided an If condition.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET