© { JSL }
61
is
·
use
is
operator to check for type support
w
returns
true
or
false
w
a cast can
throw
an InvalidCastException
static void
GreyHole(
object
o)
{
if
(o
is
IPluckable)
{
IPluckable ip = (IPluckable)o;
ip.Pluck()
...
}
}
static void
Main()
{
GreyHole(
new
Violin());
GreyHole(42);
}
check once
check twice
cast