A good example of where you might use AS is when you're testing to see if an
instance implements a specific interface, and to get hold of that interface
instance at the same time.
eg.
IWalks walker = animal as IWalks;
if (walks!=null)
{
... do something with 'walker'
}
Which is a little bit more efficient (when the instance does support the
interface) than the equivalent code:
if (animal is IWalks)
{
IWalks walker = (IWalks)animal;
... do something with 'walker'
}
--
John Wood
EMail: first name, dot, second name at priorganize.com
"John Sutor" <jo********@cinfin.com> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
Does anyone know the difference between Casting and using "AS" ?