What is the difference between this type casting expressions? What is better?
// One way
var t:MyClass = MyClass(o);
// Another
var t:MyClass = o as MyClass;
Oh, I used to know that one..
Ok, the first one will fail if it can't cast to MyClass, ie you'll end up with an exception flying up your stack.
The second one will never throw, and you'll only end up with a null value if a proper cast can't be made.
I think.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With