ctype

Difference between DirectCast() and CType() in VB.NET

落花浮王杯 提交于 2019-11-26 05:21:31
问题 I am an experienced C/C++/C# programmer who has just gotten into VB.NET. I generally use CType (and CInt, CBool, CStr) for casts because it is fewer characters and was the first way of casting which I was exposed to, but I am aware of DirectCast and TryCast as well. Simply, are there any differences (effect of cast, performance, etc.) between DirectCast and CType? I understand the idea of TryCast. 回答1: The first thing to note is that VB.NET does not have a direct analog to C#'s (type)instance