三元运算符是在哪个版本的C#中引入的?

c#

我搜索了最明显的来源,但找不到列为特定版本中引入的三元运算符。(我需要知道这些信息作为历史参考)。

回答

它在开始时在 C# 1 中被引入。

如果您需要权威来源,维基百科页面有规范的链接。C# 1.0、1.1 和 1.2的ECMA 规范说:

14.12 条件运算符

?:运算符称为条件运算符。它有时也称为三元运算符。

conditional-expression:
    conditional-or-expression
    conditional-or-expression   ?   expression   :   expression 

... 等等。

  • [Here's the _very first_ edition](https://www.ecma-international.org/wp-content/uploads/ECMA-334_1st_edition_december_2001.pdf).

以上是三元运算符是在哪个版本的C#中引入的?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>