I'm pretty new to this language, so please excuse me for not using the correct terms.
I have a function that goes like this:
private void function()
SaveFileDialog x = new SaveFileDialog;
Now, should I dispose of it at the end, or will it do it automatically. There is a bug im my program, and I am not sure whether this is the cause.

8 Years
Discussion Span
Last Post by apegram

If an object you use implements the IDisposable interface and has a Dispose method, you want to be in the habit of using it so the object can clean up its resources. The recommended way of doing so is to simply wrap the usage of the object in a using statement, which will automatically be translated by the compiler into a try/finally block that calls Dispose on the object. Example:

using (SaveFileDialog dialog = new SaveFileDialog())
   // use dialog here

By doing this, you will not need to explicitly call Dispose in your own code.

Edited by apegram: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.