Jump to content
  • Advertisement
Sign in to follow this  
jdub

Is type casting slow (C#)

This topic is 3684 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!