Jump to content
  • Advertisement
Sign in to follow this  
jdub

Is type casting slow (C#)

This topic is 3600 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
It's slower than BaseClassObject as DerivedClass, though, from what I recall, but not significantly.

Share this post


Link to post
Share on other sites
It's only slower if the conversion fails, as castclass will throw an exception while isinst will simply return null.

[Edited by - Mike.Popoloski on November 9, 2008 10:53:46 PM]

Share this post


Link to post
Share on other sites
Not so much, but the need for it is indicative of a design failure somewhere. Sometimes it's small, or saves a ton of time, or a corner case... but something that tells you to take a second look at the design. Make sure you're stepping outside the norm for a good reason.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!