Environment versions
Database:
Jet/Access Engine
>To carry this on further, as I understand it....
>
>You only need to implement Idisposable if you're going outside managed code to do something. For example, making a database connection, working with COM, etc. Otherwise, the class will cleanup on the next garbage collection.
>
>>So the question as to why one should implement the Idisposable interface at all, is one needs it if one wants to use the "using" syntax. When you do that you get a class that cleans itself up just as nicely as ... a vfp class.
>>
>>From what I understand, without the "using" statements, the idisposable is decorative, errh, is need if one wants to conform to "official" standards. :)
Not decorative. If a class implements IDisposable it is an indication that users of that class should call it's Dispose() method - either directly or indirectly using 'using'.
As Craig pointed out Dispose() only needs to be implemented if the class uses unmanaged resources.
Implement IDisposable() on any classes that you write that fall into this category.
Always check whether a .NET or third-party class implements IDisposable() and, if so, call the Dispose() method when you're finished with it. (There are exceptions to this - sometimes a class (e.g. ADO.NET Connection) will expose a Close() method and using this is preferable)
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only