C
Carl Johansson
Being quite new to C#, I may have misunderstood this. If so please bear with
me!
As far as I can understand, any instances of a class that implements the
IDisposable interface must call the Dispose method not create leaks of
resources!? This can be accomplished by explicitly calling Dispose or
through the "using" statement.
For example, a recursive method that creates hundreds or thousands of
instances of, for example, OleDbConnection, OleDbCommand, and
OleDbDataReader, would eventually cause havoc unless they were explicitly
disposed through the Dispose method or the using statement, right?
Now, if all of the above is true, what is the easiest way to identify all
classes the implement the IDisposable interface? The "Auto list members"
pop-up window i VS will show the Dispose method if it is present, but then I
must always be alert, and that, I am not! Is it possible to get the C#
compiler to generate warning messages about these classes when used?
Best Regards Carl Johansson
me!
As far as I can understand, any instances of a class that implements the
IDisposable interface must call the Dispose method not create leaks of
resources!? This can be accomplished by explicitly calling Dispose or
through the "using" statement.
For example, a recursive method that creates hundreds or thousands of
instances of, for example, OleDbConnection, OleDbCommand, and
OleDbDataReader, would eventually cause havoc unless they were explicitly
disposed through the Dispose method or the using statement, right?
Now, if all of the above is true, what is the easiest way to identify all
classes the implement the IDisposable interface? The "Auto list members"
pop-up window i VS will show the Dispose method if it is present, but then I
must always be alert, and that, I am not! Is it possible to get the C#
compiler to generate warning messages about these classes when used?
Best Regards Carl Johansson