C# 空合并运算符是否有 C++ 等价物?我在我的代码中做了太多的空检查。所以一直在寻找一种方法来减少空代码的数量。
最佳答案
我刚刚发现:The ?? operator aka the Null Coalescing Operator
You also have it in C/C++ as a GNU extension using the
?:
operator :string pageTitle = getTitle() ?: "Default Title";
关于C# null 合并运算符等效于 c++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1785426/