StreamReader
is not an unmanaged resource itself, but it wraps one, and therefore it implements IDisposable
. Anything that implements IDisposable
should be disposed. Other than that, you don't have to worry about unmanaged resources unless you're using Windows API calls via PInvoke (because anything that wraps resources allocated that way should implement IDisposable)using (StreamReader sr = new StreamReader(filename)) { txt = sr.ReadToEnd(); }
No comments:
Post a Comment