我有以下域在我的課:布爾?不能爲空
public bool? EitherObject1OrObject2Exists => ((Object1 != null || Object2 != null) && !(Object1 != null && Object2 != null)) ? true : null;
但在Visual Studio中,我得到一個智能感知錯誤不可能有「布爾」和「空」即使該字段爲空之間的轉換。 我做錯了什麼? 是否有一個更清潔的方法來檢查兩個對象中的任何一個是否爲空,但其中一個必須爲空?
我想你可能從閱讀[你的代碼難以理解嗎?](http://www.daedtech.com/code-hard-understand/)中受益博客文章由Erik Dietrich提供。 – mason
你的表情是多餘的。不是說這會解決問題,而是多餘的。 –
@Os。爲什麼它是多餘的?請解釋一下 – Palmi