In terms of coder productivity what is the quickest way in VS 2005 or 2008 to determine if Foo implements IDisposable. It has happened to me on more than one occasion that I've been caught using a type without a using
block because it never occured to me that the thing would need to implement IDisposable.
Put it in a using statement and see if it compiles:
using (var x = new TypeInQuestion(params)) {}
This won't compile if the TypeInQuestion
doesn't implement IDisposable.
The other fastest way is to use ReSharper, click on the variable (x
in this case), and see if it has a suggestion to put it in a using statement.
If you've got ReSharper, highlight the variable, wait for the lightbulb, and then hit Alt+Enter. If one of the options is "Wrap with 'using'", it's IDisposable.
Unfortunately there's no "simple simple simple" way.
You're going to have to hit F12 on the class name, and then keep hitting F12 on base classes until you're in the base class, if any of those implement IDisposable, you've got it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With