How to create and dispose the same object? I have created a form with button, on button click even I create a object and by clicking on same button I dispose the object! I m able to create a object but not able to dispose the same object. How to do it?
private void mouseClkbtn_Click(object sender, EventArgs e)
{
Project1.Form1 prjform = new Project1.Form1();
if (mouseClkbtn.Text == "Latch Enable")
{
prjform.Show();
mouseClkbtn.Text = "Latch Disable";
}
else if (mouseClkbtn.Text == "Latch Disable")
{
prjform.Hide();
prjform.Dispose();
mouseClkbtn.Text = "Latch Enable";
}
}
What is wrong with my code?