Trying to understand when implementation of IDisposable is necessary:
I wrote a little example.
public class FileManager { private FileStream fileStream; public void OpenFile(string path) { this.fileStream = File.Open(path, FileMode.Open, FileAccess.Read); } public void CloseFile(string path) { if ( this.fileStream != null && this.fileStream.CanRead) { this.fileStream.Close(); } this.fileStream.Dispose(); } } // client var manager = new FileManager(); manager.Open("path"); manager.Close("path"); Does this class need to implement IDisposable because it has a managed resource (FileStream) which holds onto an unmanaged resource (a file)? Or do I not have to implement IDisposable because I am cleaning up within the class?
Confused.
manager.Closeis called?