using (Stuff1 stf1 = new Stuff1(...)) // Allocation of stf1
using (Stuff2 stf2 = new Stuff2(...)) // Allocation of stf2
{
try
{
// ... do stuff with stf1 and stf2 here ...
}
catch (Stuff1Exception ex1)
{
// ...
}
catch (Stuff2Exception ex2)
{
// ...
}
} // Automatic deterministic destruction through Dispose() for stf1/stf2 - but in which order?
つまり、stf2 の Dispose() メソッドが最初に呼び出されることが保証され、次に stf1 の Dispose() メソッドが 2 番目に呼び出されることが保証されますか? (基本的に: Dispose() メソッドは、それらが属するオブジェクトの割り当てとは逆の順序で呼び出されますか?)