Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 嵌套使用语句_Vb.net_Using Statement - Fatal编程技术网

Vb.net 嵌套使用语句

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

正如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 Using
好吧,你可以做:

Using w1 = File.CreateText("W1"), w2 = File.CreateText("W2")
    ' Code goes here. '
End Using