Throw和Throw XX

 Try
        Catch ex As Exception
            Throw ex
        End Try
 
这么写原来是一种"愚蠢"的写法啊!
正确的写法
        Try
        Catch ex As Exception
            Throw
        End Try
除非你想抛出你自己封的错误!
 
以下是一些解释:
The Throw statement without an argument rethrows the current exception object and must appear in a Catch clause to be valid. The only other significant difference from the version that takes an argument is that the latter also resets the StackTrace property of the exception object (as if a brand-new exception were created), so the version without an argument is preferable for rethrowing the same exception when you want to let the caller routine determine exactly where the exception occurred.
大意就是Throw XX多了一层ErrorStack,影响性能!
posted @ 2006-11-08 10:51 MasterCai 阅读(...) 评论(...) 编辑 收藏