Label myLabel = new Label(); //use the label control myLabel.Dispose();
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { myLabel.Dispose(); }In this example, we override the FormClosing event handler and call the Dispose() method on our Label control. This ensures that any resources used by the control are released when the form is closed. Package library: This method is a part of the System.Windows.Forms namespace, which is included in the .NET Framework Class Library.