Hi All,

First let me state how frustrated I am with how "safe" they made C# to
the point where it feels unwieldy.

I can't wrap my head around how to properly use this interface, when
it should be used and how to implement it correctly without leaving
stuff trailing, and can't find any good explanations by searching the
internet either.

I am mostly interested in understanding the following aspects:

1. I have an instance"MyClass MyInstance = new MyClass();", I want to
call "MyInstance.Dispose()" what do I need to do to the class? What
happens to "MyInstance", is it just null now? Explain the
implementation of the method please.

2. If I explicitly implement a Dispose() method, am I now forced to
call it when an instance needs to be disposed? For example say I leave
the scope of the instance, will the dispose method be called? If so,
will it be the base or overriden one?

3. If I must implement a Dispose() method, is there a way to call a
'standard' or 'base' dispose method from the overriden method that
will clear everything else normally or will I need to define the
default actions in my version of Dispose(). In other words, say I need
to create a destructor just for the sake of handling one or two
special situations within my class, but aside from that everything
else should be disposed of normally. For example, say I have an odbc
connection/command defined in my class and I want to ensure that any
running command is canceled and the connection closed before I destroy
the class so all I really need that is out of the ordinary is a
"command.Cancel();" and "connection.Close()", everything else should
be the same, is there a way to do this simply.

If I can get some answers to these, preferably with some solid
examples I think I would feel more comfortable.

Thanks in advance!

Reply via email to