?: | Conditional |
, | Comma |
The Conditional operator is used to make a decision within
an expression, as in
int a;
// ...code that calculates 'a'
string s = a ? "True" : "False";
which is basically the same as
int a;
string s;
// ...code that calculates 'a'
if (a)
s = "True";
else
s = "False";
but the advantage of the conditional operator is that it can be used in
an expression.
The Comma operator is used to evaluate a sequence of expressions from left to right, using the type and value of the right operand as the result.
Note that arguments in a function call as well as multiple variable declarations also use commas as delimiters, but in that case this is not a comma operator!
Index | Copyright © 1999 CadSoft Computer GmbH |