Difference between revisions of "Dot.NET References"

From PeformIQ Upgrade
Jump to navigation Jump to search
Line 3: Line 3:
* http://msdn.microsoft.com/en-us/library/ms173115%28v=vs.80%29.aspx
* http://msdn.microsoft.com/en-us/library/ms173115%28v=vs.80%29.aspx
* http://www.csharp-station.com/Tutorials.aspx
* http://www.csharp-station.com/Tutorials.aspx
=Destructors and Dispose=
* http://www.codeproject.com/KB/cs/destructorsincs.aspx
<pre>
Public class MyClass:IDisposable
{
private bool IsDisposed=false;
public void Dispose()
{
  Dispose(true);
  GC.SupressFinalize(this);
}
protected void Dispose(bool Diposing)
{
  if(!IsDisposed)
  {
  if(Disposing)
  {
  //Clean Up managed resources
  }
  //Clean up unmanaged resources
}
IsDisposed=true;
}
~MyClass()
{
  Dispose(false);
}
}
</pre>




[[category:Dot.NET]]
[[category:Dot.NET]]

Revision as of 22:00, 9 September 2011

Destructors and Dispose

Public class MyClass:IDisposable
{
 private bool IsDisposed=false;
 public void Dispose()
 {
  Dispose(true);
  GC.SupressFinalize(this);
 }
 protected void Dispose(bool Diposing)
 {
  if(!IsDisposed)
  {
  if(Disposing)
  {
   //Clean Up managed resources

  }
  //Clean up unmanaged resources

 }
 IsDisposed=true;
 }
 ~MyClass()
 {
  Dispose(false);
 }
}