Search code examples
c#.netstreamdispose

Reasons to use Close over Dispose for a Stream?


Is there ever a valid reason to use the Close method on a stream instead of Dispose?


Solution

  • Only in System.Windows.Forms.Form and System.Data.SqlClient.SQLConnectoin do Close and Dispose have different behavior. This has to do with dispose being hidden in situations where the behavior was not clear in context. This is more deeply explained here MSDN Difference Between Close and Dispose