Vb.net 嵌套使用语句
正如Eric Gunnerson在博客文章中所示,在C#中,您可以使用语句嵌套Vb.net 嵌套使用语句,vb.net,using-statement,Vb.net,Using Statement,正如Eric Gunnerson在博客文章中所示,在C#中,您可以使用语句嵌套,如下所示: 使用(StreamWriter w1=File.CreateText(“w1”)) 使用(StreamWriter w2=File.CreateText(“w2”)) { //代码在这里 } 在VB.Net中有类似的方法吗?我希望避免太多的缩进级别。如下所示: Using a As New Thingy(), _ b As New OtherThingy() ... End
,如下所示:
使用(StreamWriter w1=File.CreateText(“w1”))
使用(StreamWriter w2=File.CreateText(“w2”))
{
//代码在这里
}
在VB.Net中有类似的方法吗?我希望避免太多的缩进级别。如下所示:
Using a As New Thingy(), _
b As New OtherThingy()
...
End Using
好吧,你可以做:
Using w1 = File.CreateText("W1"), w2 = File.CreateText("W2")
' Code goes here. '
End Using