📅  最后修改于: 2022-03-11 14:44:45.761000             🧑  作者: Mango
The Conditional (or Ternary) Operator (?:)
(expression 1) ? expression 2 : expression 3
If expression 1 evaluates to true, then expression 2 is evaluated.
If expression 1 evaluates to false, then expression 3 is evaluated instead.
// ternary operator checks if
// marks is greater than 40
int marks = 50;
string result = (marks >= 40) ? "passed" : "failed";
// result = "passed"