Freigeben über


Close and Dispose...

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

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

Comments

  • Anonymous
    December 11, 2004
    The site is down at the moment. What is the answer?!? :)

    - Joshua
  • Anonymous
    December 11, 2004
    Both, preferably, but Dispose() will close the stream as well and thus is 'required'.
  • Anonymous
    December 11, 2004
    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!
  • Anonymous
    December 11, 2004
    I say just place it in a using block and let the compiler deal with it. <grin>
  • Anonymous
    December 12, 2004
    Should probably call both, but Close() will call Dispose(), so Close() is the only one you really need to be calling.