using (SpreadSnapshot oSnap = new SpreadSnapshot())
using (oSnap.SetRowCol(fpSpread, row, col))
{
SpreadSetComboBox(fpSpread, list, displayProperty);
}
The two mean completely different things, unless SetRowCol returns this at the end. In the first, you're disposing the results of SetRowCol. In the second, you're disposing the SpreadSnapshot.
If both are disposable, you should do a using for both:
using (SpreadSnapshot oSnap = new SpreadSnapshot())
using (oSnap.SetRowCol(fpSpread, row, col))
{
SpreadSetComboBox(fpSpread, list, displayProperty);
}
发布评论
评论(2)
后者 - 它确保您不会在
using
语句之后使用oSnap
。抛开其他事情不谈,
SetRowCol
返回一些一次性的东西会很奇怪......这意味着什么?The latter - it ensures that you don't end up using
oSnap
after theusing
statement.Aside from anything else, it would be pretty odd for
SetRowCol
to return something disposable... what would that even mean?两者的含义完全不同,除非
SetRowCol
最后返回this
。首先,您要处理SetRowCol
的结果。在第二步中,您将处理SpreadSnapshot
。如果两者都是一次性的,您应该对两者进行使用:
The two mean completely different things, unless
SetRowCol
returnsthis
at the end. In the first, you're disposing the results ofSetRowCol
. In the second, you're disposing theSpreadSnapshot
.If both are disposable, you should do a using for both: