what are function clr in .net 3.5 is there anything change

Posted by Jameschowdare under Regular Expressions on 2/4/2010 | Views : 2463 | Status : [Member] | Replies : 3
what is dispose and finaly where and exactly used them in acutall app implemntations




Responses

Posted by: Vuyiswamb on: 2/4/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
It is good to release the object after you use them. We have Garbage Collector but we cant invoke it, it comes at its own time. So after you use an object or Connection its good to Display it. and the best place to do this is in the Finally block

BLL obj = new BLL();


try
{
obj.DisableSete();
}
catch(ApplicationException ex)
{
throw;
}
Finally
{
obj = null;
}


Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 2/4/2010 [Member] Starter

Up
0
Down
finally and dispose are altogether two difference thing and in no way can be compared.

finally is the option block to use while error handling in .NET.

for example you can use

try
{

}
catch
{

}
finally // optional
{

}


Finally ensures that whether error occurred in the try block or not, the code inside the finally block will execute. That is why people generally use dispose method of an object like SqlConnection or SqlCommand in finally block to ensure that these objects are disposed in all cases.

Hope this helps, if yes "Mark as Answer".

Thank you


Regards,
Raja, USA

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 2/4/2010 [Member] Bronze

Up
0
Down
If the object that you have created is the Member of IDisposable class the dispose mechanism can be handled in the class itself.

public class clsClassName : IDisposable
{

}

Here IDisposable is the Interface, so you have to implement the Methods of it.

In that method you can dispose the current object.

Jameschowdare, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response