语句中的问号和冒号.这是什么意思? [英] Question mark and colon in statement. What does it mean?
本文介绍了语句中的问号和冒号.这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问号 (?
) 和冒号 (:
) 是什么意思?
What do the question mark (?
) and colon (:
) mean?
((OperationURL[1] == "GET") ? GetRequestSignature() : "")
它出现在以下语句中:
string requestUri = _apiURL + "?e=" + OperationURL[0] + ((OperationURL[1] == "GET") ? GetRequestSignature() : "");
推荐答案
这是条件运算符表达式.
This is the conditional operator expression.
(condition) ? [true path] : [false path];
例如
string value = someBooleanExpression ? "Alpha" : "Beta";
因此,如果布尔表达式为真,则 value 将保存为Alpha",否则保存为Beta".
So if the boolean expression is true, value will hold "Alpha", otherwise, it holds "Beta".
有关人们陷入的常见陷阱,请参阅这个问题 在 C# 标签维基中.
For a common pitfall that people fall into, see this question in the C# tag wiki.
这篇关于语句中的问号和冒号.这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文