Casting DataTypes with DirectCast, CType, TryCast

后端 未结 4 1963
半阙折子戏
半阙折子戏 2020-12-01 05:22

Ever since I moved from VB6 to VB.NET somewhere in 2005, I\'ve been using CType to do casting from one data type to another. I do this because it is simply faster to type, u

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 05:44

    DirectCast is twice as fast for value types (integers...etc), but identical for reference types.

    For more information see the "Conversion Functions, CType, DirectCast, and System.Convert" section on this MSDN page.

提交回复
热议问题