30

Eric Gunnersonがこのusingブログ投稿で示しているように、C#ではステートメントを次のようにネストできます。

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

VB.Netでそれを行う同様の方法はありますか?インデントレベルが多すぎないようにします。

4

2 に答える 2

42

このような:

Using a As New Thingy(), _
      b As New OtherThingy()
        ...
End Using
于 2010-07-27T15:52:28.207 に答える
5

さて、あなたはすることができます:

Using w1 = File.CreateText("W1"), w2 = File.CreateText("W2")
    ' Code goes here. '
End Using
于 2010-07-27T15:56:28.790 に答える