Re: knowing the interfaces that an object implements

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Well what do you know I completely missed the lack of explicit cast! Talk
about seeing what you expect to see :-)

Nick Hall
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1cdb208c7c0519de98c055@xxxxxxxxxxxxxxxxxxxxxxx
> Nick Hall <nickh@xxxxxxxxxxxxxxxxxx> wrote:
>> It's not evaluated until runtime - therefore it actually does work. It
>> uses
>> the IL instruction isinst to make the determination.
>
> The "if" does, but the call to Dispose should fail at compile time,
> because the compiler doesn't know that connection implements
> IDisposable. Of course, with Option Strict turned off it would be okay,
> but personally I think type-safety is rather important :)
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too


.