In a class that contains only managed resources C# with Example



In a class that contains only managed resources C# with Example

Managed resources are resources that the runtime's garbage collector is aware and under control of. There are 
many classes available in the BCL, for example, such as a SqlConnection that is a wrapper class for an unmanaged 
resource. These classes already implement the IDisposable interface -- it's up to your code to clean them up when 
you are done. 
It's not necessary to implement a finalizer if your class only contains managed resources. 
public class ObjectWithManagedResourcesOnly : IDisposable 
{ 
private SqlConnection sqlConnection = new SqlConnection(); 
public void Dispose() 
{ 
sqlConnection.Dispose(); 
} 
} 

0 Comment's

Comment Form

Submit Comment