다음을 통해 공유


VB.NET Keyword of the Week: DirectCast

I'm starting a new series of blog entries - a weekly keyword in VB.NET that I find interesting, and that some of you may not be aware of.

This weeks word: DirectCast. If you've been using CType to convert values, as in var=CType(expression, typename), consider using DirectCast instead. You can use DirectCast as long as the run-time type of the object variable is the same as the specified type, rather than merely having a valid conversion defined. You'll get better performance. Check out the documentation on DirectCast for more details.

Comments

  • Anonymous
    June 03, 2004
    The comment has been removed
  • Anonymous
    June 04, 2004
    Thanks, Max. That's a great write-up you've done on conversions.