2010-07-27 16 views
24

Come Eric Gunnerson spettacoli in this post del blog, in C# si può annidare using affermazioni come:nidificati che utilizzano le dichiarazioni

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

C'è un modo simile per farlo in VB.Net? Voglio evitare troppi livelli di indentazione.

risposta

34

Ti piace questa:

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

Beh, si può fare:

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