Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
select new { Selected = (cvf != null && cvf.Deleted==false) }
即使 cvf 为空,上述语句也会继续检查 cvf.Deleted。然后它抛出一个无效的对象引用错误。
我该如何解决?
&& 可能会 发生其他事情,因为短路评估。也就是说,试试这个:
&&
select new { Selected = cvf != null ? !cvf.Deleted : false };