Wednesday, July 1, 2009

to dispose Form or not: Not

public void ShowForm()
{
    try
  
{
        MyForm form = newMyForm ();
        form.ShowModal();

    }
catch (Exception)
{
}finally
{


form = null



         or     


form.Dispose()   



}



}


I’ve seen that before. No need. Window.Close already disposes the form. And assigning the form to null might feel comfortable for C++ers but makes no difference in C# world.


0 comments:

Post a Comment