CType(cn, IDisposable).Dispose()
Treat(an object, as an IDisposable interface).and call Dispose method on the
result.
If cn is a variable that points to an ADO.NET connection object the code
below will work because ADO.NET connection objects implement the IDisposable
interface's Dispose method as a public method you can call directly.
cn.Dispose()
--
Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
"Eric Sabine" <mopar41@___ho_y_tmail.ScPoAmM> wrote in message
news:%(E-Mail Removed)...
> In my Finally block, I was using cn.close (where cn is an ADO.NET
> connection object, SQLConnection to be exact) and then I came across the
> following in some microsoft code.
>
> If Not cn Is Nothing Then
> CType(cn, IDisposable).Dispose()
> End If
>
> I have to admit, I'm not sure what happens here. Will someone explain
this
> line of code (the middle one, not the if statement LOL) to me please?
> [hopefully I won't get flamed for this :-) ]
>
> Eric
>
>
>