Ternary Operator (?) is one of code optimization technique in axapta .It acts as a IF condition in axapta
Syntax :
Syntax :
expression1 ? expression2 : expression3
expression1 must be a Boolean expression. If expression1 is true, the whole ternary statement resolves to expression2; otherwise it resolves to expression3.
expression2 and expression3 must be of the same type as each other.
Example :
By using Ternary operator(?):
int nVar = 2;
;
print nVar < 3 ? nVar + 1 : nVar - 1; // print output 3.
pause;
Same Code By using If() Condition:
int nVar = 2;
;
if(nVar < 3)
{
nVar = nVar +1;
}
else
{
nvar = nvar-1;
}
// print output 3.
Thanks for the detailed explanation of the ternary operator in Axapta 2012! By the way, if you're into handy tech gadgets for development or testing, you might want to check out the flipper zero irdb it’s a powerful tool for many tasks.
ReplyDelete