VB actually has 2 concepts of casting.
- CLR casting
- Lexical casting
CLR style casting is something that is more familiar to a C # user. It uses a CLR type and conversion system to perform the cast. VB has DirectCast and TryCast equivalent to the C # operator and as the operator, respectively.
VB lexical throws do extra work in addition to a CLR type system. They are actually a superset of potential castings. Lexical drops are easily recognized when looking for the C prefix in the casting operator: CType, CInt, CString, etc. These castings, if they are not directly known to the compiler, will go through VB runtime. Runtime will interpret on top of the type system to allow the following actions to be performed:
Dim v1 = CType("1", Integer) Dim v2 = CBool("1")
Jaredpar
source share