On Thu, 2002-06-27 at 12:07, Jaime Anguiano Olarra wrote:
> Yes!. Sorry, I might be too blind. :-/
> 
> Thanks,
> 
> Jaime.
> 
> El jue, 27-06-2002 a las 12:08, Dwivedi , Ajay Kumar escribi�:
> > > if (modem is ISpherical)
> > > {
> > >   ISpherical isModem = (ISpherical) modem;
> > >   modem.Roll();
> > > }

btw:

you're generating _two_ identical typechecks with these statements.
one explicit via 'is' and an implicit second check during the actual
cast, after the original one already succeeded.
good compilers might optimize this away in future. afaik, csc currently
doesn't.

a more efficient version in C# is written by using the 'as' keyword,
which gets you a null if the type is incompatible.

ISpherical isModem = modem as ISperical;
if ( isModem )
        ..
else
        ..

see?


regards,
dns

-- 
___________________________________________________________________________
 mailto:[EMAIL PROTECTED]


_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to