CSharp中的?.运算符


在编译chromiumFX工程时候,编译失败,无法正常工作。是运算符 (?.)的错误,经过查找,该运算符

参考NULL 条件运算符(C# 和 Visual Basic)

用于在执行成员访问 (?.) 或索引 (?[) 操作之前,测试是否存在 NULL。 这些运算符可帮助编写更少的代码来处理 null 检查,尤其是对于下降到数据结构。

int? length = customers?.Length; // null if customers is null   
Customer first = customers?[0];  // null if customers is null  
int? count = customers?[0]?.Orders?.Count();  // null if customers, the first customer, or Orders is null  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM