Re: knowing the interfaces that an object implements



It's not evaluated until runtime - therefore it actually does work. It uses
the IL instruction isinst to make the determination.

Hope this helps,

Nick Hall

"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1cd9d4b0b54c9ec798c045@xxxxxxxxxxxxxxxxxxxxxxx
> Jakob Christensen <jch@xxxxxxxxxxxxxxxx> wrote:
>> I am no VB.net expert but I believe the following will work:
>>
>> If TypeOf connection Is IDisposable Then
>> connection.Dispose()
>> End If
>
> I don't believe it should, if Option Strict is on. The compiler still
> doesn't know that connection implements IDisposable - it doesn't
> understand the consequences of the "if" passing.
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too


.


Loading