I know this might seem impossible at first and it seemed that way to me at first as well, but recently I have seen exactly this kind of code throw a NullReferenceException, so it is definitely possible.
Unfortunately, there are pretty much no results on Google that explain when code like foo == null
can throw a NRE, which can make it difficult to debug and understand why it happened. So in the interest of documenting the possible ways this seemingly bizzare occurance could happen:
In what ways can this code foo == null
throw a NullReferenceException?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…