HighTechTalks DotNet Forums  

Use of idisposable interface.

Dotnet Framework microsoft.public.dotnet.framework


Discuss Use of idisposable interface. in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Archana
 
Posts: n/a

Default Use of idisposable interface. - 12-27-2007 , 02:06 AM






Hi all,

Can anyone tell me exact use of idisposable interface.

I read that to release unmanages resources its better to implement
idisposable interface and call its dispose method.

But what if without implementating interface idisposable i write
method dispose and call that method to release unmanaged resources.

Please correct me if i am wrong.

thanks in advance.

Reply With Quote
  #2  
Old   
Jack Jackson
 
Posts: n/a

Default Re: Use of idisposable interface. - 12-27-2007 , 02:56 AM






On Wed, 26 Dec 2007 23:06:17 -0800 (PST), Archana
<trialproduct2004 (AT) yahoo (DOT) com> wrote:

Quote:
Hi all,

Can anyone tell me exact use of idisposable interface.

I read that to release unmanages resources its better to implement
idisposable interface and call its dispose method.

But what if without implementating interface idisposable i write
method dispose and call that method to release unmanaged resources.

Please correct me if i am wrong.

thanks in advance.
You can do that. However, IDisposable is better, as it allows you to
use the "using" syntax to insure that Dispose is always called, even
if an exception occurs.

Using IDispose is also slightly better because it allows you to call
the Dispose method without having to know the type of the object,
although in practice this probably rarely occurs.


Reply With Quote
  #3  
Old   
Michael Nemtsev [MVP]
 
Posts: n/a

Default Re: Use of idisposable interface. - 12-27-2007 , 03:58 AM



Hello archana,

see there http://msdn.microsoft.com/msdnmag/is.../CLRInsideOut/

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


a> Can anyone tell me exact use of idisposable interface.
a>



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.