正如Eric Gunnerson在this博客文章中所展示的那样,在C#中,您可以将using语句嵌套为:
using (StreamWriter w1 = File.CreateText("W1"))
using (StreamWriter w2 = File.CreateText("W2"))
{
// code here
}在VB.Net中有没有类似的方法呢?我想避免太多的缩进级别。
发布于 2010-07-27 23:52:28
如下所示:
Using a As New Thingy(), _
b As New OtherThingy()
...
End Using发布于 2010-07-27 23:56:29
好的,你可以这样做:
Using w1 = File.CreateText("W1"), w2 = File.CreateText("W2")
' Code goes here. '
End Usinghttps://stackoverflow.com/questions/3345303
复制相似问题