【发布时间】:2011-08-24 15:38:38
【问题描述】:
在下面的子程序中,抛出异常时StreamReader会正确关闭吗?还是我自己做了一些事情来确保这一点?
Sub mySub()
Dim sr As StreamReader = File.OpenText("someFilename")
Dim line As String = sr.ReadLine()
While Not (line Is Nothing)
' Some logic here
If someCondition Then
Throw New Exception("someExplanation")
End If
line = sr.ReadLine()
End While
End Sub
【问题讨论】:
标签: vb.net exception streamreader