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()方法保证第二个被调用?(基本上:Dispose() 方法的调用顺序与它们所属对象的分配顺序相反?)