Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
In Line IF - Speed question or compiler issue
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00922714
Message ID:
00922721
Views:
21
Just a guess but I would imagine that the normal if would be faster than the inline if in this case. You do 3 variable assignments in both cases but in the normal if case you only evaluate TestExpression once comared to 3 times in the inline if.

Just my 2 pennies worth.

Einar

>I have seen some code that uses the In-line IF (My words not the help file)
>
>
>expression ? trueCondition : falseCondition
>
>
>What is faster in code execution in line or straight IF structure?
>
>i.e.
>
>Is this faster than :
>
>if (TestExpression)
>{
>   DoSomething1 = true;
>   Dosomething2 = true;
>   DoSomething3 = false;
>}
>else
>{
>   DoSomething1 = false;
>   Dosomething2 = false;
>   DoSomething3 = true;
>
>}
>
>
>this..
>
>
>DoSomething1 = TestExpression ? true : false;
>Dosomething2 = TestExpression ? true : false;
>DoSomething3 = TestExpression ? false : true;
>
>
>
>
>Thanks!
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform