Close and Dispose…

Joe has a little quiz about Close() and Dispose()

Trivia: Should you call Close() and/or Dispose() on a Stream?


Comments (7)

  1. Joshua Bair says:

    The site is down at the moment. What is the answer?!? 🙂

    – Joshua

  2. Frederik says:

    Both, preferably, but Dispose() will close the stream as well and thus is ‘required’.

  3. Matt says:

    Without consulting anything, aren’t they both achieving the same end of disposing the stream resources? With .Close() just being more intuitive for people coming from various programming backgrounds. I’d be interested in knowing the reality, so someone correct my ignorance!

  4. William Robertson says:

    I say just place it in a using block and let the compiler deal with it. <grin>

  5. Should probably call both, but Close() will call Dispose(), so Close() is the only one you really need to be calling.

Skip to main content