Is there a list of common object that implement IDisposable for the using statement?

前端 未结 9 2388
挽巷
挽巷 2020-12-17 15:10

I was wondering if there was some sort of cheat sheet for which objects go well with the using statement... SQLConnection, MemoryStream, etc.

9条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-17 16:00

    An simple way to get a list of types that implement IDisposable is to crack open Reflector, navigate to System.IDisposable, expand the node, and then expand the 'Derived Types' node.

    To be sure that your list is complete, verify that all the assemblies you're using have been 'Open'ed in Reflector.

提交回复
热议问题