在尝试维护别人的代码时,我发现了这个小宝石: Catch ex As Exception If Not ex Is Nothing Then ... End IfFinally 有没有时间发生这种情况我不知道?我应该将这些添加到我的代码中吗? 如果你试试
          Catch ex As Exception
   If Not ex Is Nothing Then
     ...
   End If
Finally 
 有没有时间发生这种情况我不知道?我应该将这些添加到我的代码中吗?
如果你试试这个:Try
    Dim x As Exception = Nothing
    Throw x
Catch ex As Exception
    Debug.Print(ex.ToString())
End Try 
 ex将是一个System.NullReferenceException. Throw statement文档没有提到如果传递空引用会发生什么,但OpCodes.Throw文档说:
NullReferenceException is thrown if the object reference is a null reference.
所以,我相信答案是前者永远不会是无.
