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.
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.