Background
In Visual Studio 2008 Create a new Windows Forms Application, this will create a skeleton project with a class called "Form1". VS2008 automatically creates a Dispose() method.
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
I wandered into a coworker's office (a senior developer) - great guy, smart, good design skills for a chat - but I noticed what he was typing - as he navigated the codebase he deleted this section of the Dispose() methods that VS2008 created for the forms.
if (disposing && (components != null))
{
components.Dispose();
}
So, I asked him why and he said it wasn't necessary to keep it in.
The Questions
- Is it safe to delete this code?
- What are the pros/cons of leaving it in or removing it?