What's the purpose of implementing the IDisposable interface?

后端 未结 5 1097
无人及你
无人及你 2021-01-13 13:05

What\'s the purpose of implementing the IDisposable interface? I\'ve seen some classes implementing it and I don\'t understand why.

5条回答
  •  半阙折子戏
    2021-01-13 13:42

    If your class creates unmanaged resources, then you can implement IDisposable so that these resources will be cleaned up properly when the object is disposed of. You override Dispose and release them there.

提交回复
热议问题