Search code examples
c#using

How do I know which objects I can use the keyword USING in C#?


Given that the keyword "using" should always be used when applicable, I wanted to go with that. The problem is, how do I know which objects I can use USING?


Solution

  • You can use tools like FxCop or CodeRush to identify code where you don't call Dispose/use using on objects implementing IDisposable. They will warn you in this case.

    Also, in Visual Studio, you can use the Object Browser to see which types implement IDisposable.

    enter image description here