views:

307

answers:

2

What is the difference between:

Car(someObject).isRacing;

and

(someObject as Car).isRacing;

Thanks in advance!

+4  A: 

Casting using Car(someObject) will throw an error if someObject is not of type Car or does not extend Car, whereas someObject as Car will merely return null if some object is not of type Car or extends Car.

quoo
+2  A: 

Here's an earlier thread on this same topic, you'll find lots of details in there.

Link

Tyler Egeto