VB CStr, CDate, CBool, etc. vs. DirectCast for casting without conversion

前端 未结 3 1373
走了就别回头了
走了就别回头了 2021-01-06 04:56

I usually avoid VB\'s built-in conversion functions (CStr, CDate, CBool, CInt, etc.) unless I need to do an actual conversion. If I\'m just casting, say from an object to a

3条回答
  •  清酒与你
    2021-01-06 05:46

    Most of the time, I use CStr, CInt, CBool and CType because it's shorter and easier to read. There might be a slight performance cost but most of the time it doesn't matter. It's good to know the differences between CType, TryCast, DirectCast, and others though.

提交回复
热议问题