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