Re: SqlConnection DOES implement IDispose

From: Mickey Williams [C# MVP] (my)
Date: 10/13/04


Date: Wed, 13 Oct 2004 14:52:30 -0700


"Richard" <Richard@discussions.microsoft.com> wrote in message
news:046E15E3-0493-4E15-AE22-F3AC74084F93@microsoft.com...

> You can use SqlConnection in a using statement - I assume that base class
> implements IDispose...

SqlConnection implements IDisposable via the Component base class and
IDbConnection, sort of like this:

class Component: IDisposable
{
 public void Dispose(){
     Dispose(true);
  }
 protected virtual void Dispose(bool disposing){}
}

interface IDbConnection: IDisposable
{
}

class SqlConnection: Component, IDbConnection
{
 protected override void Dispose(bool disposing) {
  base.Dispose (disposing);
 }
}

-- 
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com