What does object?.Property mean in c#
本问题已经有最佳答案,请猛点这里访问。
我最近在浏览别人的代码时遇到了这个问题
1 | var name = Product.Buyer?.FirstName +"" + Product.Buyer?.LastName; |
这(
运算符
Used to test for null before performing a member access (?.) or index
(?[) operation. These operators help you write less code to handle
null checks, especially for descending into data structures.
请参阅文档和此处的示例