VB.NET: Boolean from `Nothing` sometimes `false`, sometimes Nullreference-Exception
问题 Coming from Basic boolean logic in C# , I was wondering why: Dim b As Boolean Dim obj As Object = Nothing 'followig evaluates to False' b = DirectCast(Nothing, Boolean) 'This throws an "Object reference not set to an instance of an object"-Exception' b = DirectCast(obj, Boolean) A CType(obj, Boolean) would evaluate to False (just as CBool(obj)) . I think it is because the compiler uses a helper function, but that is not my theme. Why does casting Nothing to Boolean evaluates to False ,