I am in a way to refactor,where I came across this weird code. It seems like a self contradicting code to me. Am I right? I just want to know potential issues with this. Kindly note same code has been used at many places where there are File Operations, Network operations and Un-managed resources usages and needs a proper cleanup.
class xyz
{
//my class members having n/w , file operations
public void SomeFileIOActivity()
{
//File R/W operation codes
}
//Dispose method
public void Dispose()
{
if (!_disposed)
{
_disposed = true;
}
GC.SuppressFinalize(this);
}
//destructor
~FileComparer()
{
Dispose();
}
}
Its usage in another class
var o = new xyz();
o.SomeFileIOActivity();