Today, I wanted to perform an operation with a file so I came up with this code
class Test1
{
Test1()
{
using (var fileSt
I think that the question is more like "Should I dispose the file immediately or with the Dispose method of the class that accesses to that file?"
It depends: if you access the file only in the constructor in my opinion there is no reason to implement the IDisposable. Using is the right way
Otherwise if you use the same file also in other methods, maybe it's a good practise open the file once and be sure to close it in your Dispose method (implementing the IDisposable)