Question

I'm working on a projact where i convert j# UI code to C#. in the old code (j#) there was a class extends Form, and method:

public void dispose()
{
   super.dispose();
   components.dispose(); 
}

after changing the imports from: com.ms.wfc.ui to system.windows.form the compiler is asking me to change super.dispose() to super.Dispose(). (same with component).

My question is if i need to change the method above to Dispose as well? in the J# code it doesnt say if this is override or not, and i think if i dont change it, dispose() will not be call whan this form is close

Was it helpful?

Solution

You don't need to declare the Dispose method as override, it's enough if you change it to Dispose().

public class MyClass : IDisposable
{
    public void Dispose()
    {
        // Perform any object clean up here.

        // If you are inheriting from another class that
        // also implements IDisposable, don't forget to
        // call base.Dispose() as well.
    }
}

Here is a good tutorial on using Dispose in C#: http://www.codeproject.com/Articles/15360/Implementing-IDisposable-and-the-Dispose-Pattern-P

OTHER TIPS

C# is case-sensitive. And if you want to override the IDIsposable interface method implementation of the form, you must write is with the capital letter:

public void Dispose()
{
   //...
}

Hope, I understood your problem correctly...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top