If your catch statement needs to access the variable declared in the using statement, then inside this is your only option.
If your catch statement needs an object referenced by usage before it is deleted, then your only option.
If your catch statement takes an action of unknown duration, for example, displaying a message to the user, and you would like to get rid of your resources before this happens, then the external option is your best option.
Whenever I have a scenerio like this, the try-catch block is usually located in another method, located further from the call stack from use. It is not typical for a method to know how to handle exceptions that occur inside it like this.
So my general recommendation goes out.
private void saveButton_Click(object sender, EventArgs args) { try { SaveFile(myFile);
Jeffrey L Whitledge May 26 '11 at 21:29 2011-05-26 21:29
source share