三元运算符是在哪个版本的 C# 中引入的?
In which version of C# was the ternary operator introduced?
我搜索了最明显的来源,但找不到列为在特定版本中引入的三元运算符。 (我需要知道这些信息作为历史参考)。
一开始就在 C# 1 中引入了。
如果你想要一个权威来源,C# 1.0、1.1 和 1.2 的 Wikipedia page has links to the specifications. The ECMA Spec 说:
14.12 Conditional operator
The ?:
operator is called the conditional operator. It is at times also called the ternary operator.
conditional-expression:
conditional-or-expression
conditional-or-expression ? expression : expression
...等等。
我搜索了最明显的来源,但找不到列为在特定版本中引入的三元运算符。 (我需要知道这些信息作为历史参考)。
一开始就在 C# 1 中引入了。
如果你想要一个权威来源,C# 1.0、1.1 和 1.2 的 Wikipedia page has links to the specifications. The ECMA Spec 说:
14.12 Conditional operator
The
?:
operator is called the conditional operator. It is at times also called the ternary operator.conditional-expression: conditional-or-expression conditional-or-expression ? expression : expression
...等等。