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

前端 未结 9 2404
挽巷
挽巷 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 15:58

    If you are unsure whether a class implements IDisposable or not, enclose it in a using block regardless. If you get a compile error, just remove it. You'll only lose a few seconds typing time.

提交回复
热议问题