You do not need to destroy managed code as Garbage collector takes care of it. Ideally any class that inherits IDisposable interface should be called with using block like
using (SqlConnection conn = new SqlConnection())
{
}
OR with try, catch and finally
SqlConnection conn = new SqlConnection()
try
{
//.....
conn.Open();
// do your work
// conn.Close();
}
catch(Exception ex)
{
}
finally
{
conn.Dispose();
}
Alternatively you can call GC.Collect() function.
To destroy unmanaged code, either call their Dispose or Close object or set their variable value to null.
Thanks, hope this helps.
Regards,
Sheo Narayan
http://www.dotnetfunda.com
Kasani007, if this helps please login to Mark As Answer. | Alert Moderator