2010-07-27 18 views
24

Comme Eric Gunnerson montre en post blog this, en C#, vous pouvez imbriquer des déclarations using comme:emboîtés à l'aide des déclarations

using (StreamWriter w1 = File.CreateText("W1")) 
using (StreamWriter w2 = File.CreateText("W2")) 
{ 
    // code here 
} 

Y at-il une manière similaire à le faire en VB.Net? Je veux éviter trop de niveaux d'indentation.

Répondre

34

Comme ceci:

Using a As New Thingy(), _ 
     b As New OtherThingy() 
     ... 
End Using 
4

Eh bien, vous pouvez le faire:

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