It is good practice to never rely on the Garbage Collector (GC) to clean up your objects for you. Not only will this improve the preformance of your application over it can help prevent strange errors when dealing with, for example, I/O operations.
A good example of why you should do this would be sending an email with an attachment from the local file system. When you call this line of code:
A lock is actually going to be placed on the file that is specificed in 'somefile' and this lock will remain in place until mailMsgObj.Dispose() is called to release the resource.
To avoid calling Dispose() on all of my objects I prefer using statements such as:
Once execution has passed outside the scope of the using block your objects will be destroyed.
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click
on their post!
"Easy is the path to wisdom for those not blinded by themselves."