Answer: Finally block is the best place to release all the objects as
Try
{
}
Catch
{
}
Finally
{
//Always check whether object is null or not.
if (con != null)
con.Close();
if(ds != null)
ds.Dispose();
//Here con is our SqlConnection object and ds is our DataSet object.
}
Asked In: Many Interviews |
Alert Moderator