VB.net函数中的Try结构,若在catch到错误时执行了Return语句,Finally后的语句会否执行?
如下所示,Finally后面的关闭连接的语句会不会执行?
Function setCompID() As Boolean
Conn.Open() '打开连接
Try
...
Catch
Return False
Finally
Conn.Close() '关闭连接
End Try
End Function
如下所示,Finally后面的关闭连接的语句会不会执行?
Function setCompID() As Boolean
Conn.Open() '打开连接
Try
...
Catch
Return False
Finally
Conn.Close() '关闭连接
End Try
End Function
====CSDN 小助手 V2.5 2005年11月05日发布====
CSDN小助手是一款脱离浏览器也可以访问Csdn论坛的软件
界面:http://blog.csdn.net/Qqwwee_Com/archive/2005/11/05/523395.aspx
下载:http://szlawbook.com/csdnv2
imports System
imports System.Collectionspublic module MyModule
sub Main
A.Test()
Console.ReadLine()
end subend moduleClass A shared sub Test()
try
dim i as integer = CType("a",integer)
catch
Console.WriteLine("catch")
finally
Console.WriteLine("finally")
end try
end sub
end class
试一下就知道了。